195 lines
9.9 KiB
XML
195 lines
9.9 KiB
XML
<?xml version="1.0"?>
|
|
<project name="a4e-jdt-macros" basedir="." xmlns:ant4eclipse="antlib:org.ant4eclipse">
|
|
|
|
<!-- define ant4eclipse tasks -->
|
|
<taskdef uri="antlib:org.ant4eclipse" resource="org/ant4eclipse/antlib.xml" />
|
|
|
|
<!-- ===============================================================================================================
|
|
macro: createCompilerOptionFile
|
|
|
|
Generates an option file used for the compilation process. Especially useful to generate preferences with
|
|
default settings.
|
|
|
|
Parameters:
|
|
- destination: the location where the file will be written to.
|
|
- sourcelevel: the language level for the sources.
|
|
- targetlevel: the level for the generated byte code.
|
|
==============================================================================================================
|
|
-->
|
|
<macrodef name="createCompilerOptionFile">
|
|
<attribute name="destination"/>
|
|
<attribute name="sourcelevel" default="1.5"/>
|
|
<attribute name="targetlevel" default="1.5"/>
|
|
<sequential>
|
|
<echo file="@{destination}">eclipse.preferences.version=1${line.separator}</echo>
|
|
<echo file="@{destination}" append="true">org.eclipse.jdt.core.compiler.codegen.targetPlatform=@{targetlevel}${line.separator}</echo>
|
|
<echo file="@{destination}" append="true">org.eclipse.jdt.core.compiler.compliance=@{targetlevel}${line.separator}</echo>
|
|
<echo file="@{destination}" append="true">org.eclipse.jdt.core.compiler.source=@{sourcelevel}${line.separator}</echo>
|
|
</sequential>
|
|
</macrodef>
|
|
|
|
<!-- ===============================================================================================================
|
|
macro: buildJdtProject
|
|
|
|
builds a single JDT-based eclipse project
|
|
Parameters:
|
|
- workspace: the root directory of the workspace that contains the JDT project
|
|
- projectName: the name of the project that should be built (must exist in the workspace)
|
|
- targetPlatformId (optional): the id of the target platform that should be used when working with pde-projects
|
|
The following parameters control the source and target level:
|
|
- defaultCompilerOptionsFile (optional): A file that is used to set default compiler options
|
|
- targetLevel (optional): Specifies the class file version that should be generated by the compiler
|
|
- sourceLevel (optional): Specifies language version of the source files. Defaults to targetLevel.
|
|
Note: you only should set defaultCompilerOptionsFile *or* targetLevel/sourceLevel. If both are set,
|
|
defaultCompilerOptionsFile 'wins', i.e. overrides the target/sourceLevel argument
|
|
==============================================================================================================
|
|
-->
|
|
<macrodef name="buildJdtProject" description="builds a single JDT-based eclipse project">
|
|
<attribute name="workspaceDirectory" />
|
|
<attribute name="projectName" />
|
|
<attribute name="targetPlatformId" default="" />
|
|
<attribute name="defaultCompilerOptionsFile" default=""/>
|
|
<attribute name="targetLevel" default=""/>
|
|
<attribute name="sourceLevel" default="@{targetLevel}"/>
|
|
|
|
<!-- element definitions for lifecycle phases -->
|
|
<element name="initialize"
|
|
optional="true"
|
|
description="Initialize build state, e.g. set properties or create directories." />
|
|
<element name="generate-sources"
|
|
optional="true"
|
|
description="Generate any source code for inclusion in compilation." />
|
|
<element name="generate-resources"
|
|
optional="true"
|
|
description="Generate resources for inclusion in the package." />
|
|
<element name="pre-compile"
|
|
optional="true"
|
|
description="Execute additional steps before compilation." />
|
|
<element name="post-compile"
|
|
optional="true"
|
|
description="Post-process the generated files from compilation, for example to do bytecode enhancement on Java classes." />
|
|
<element name="post-copy-resources"
|
|
optional="true"
|
|
description="Post-process a source folder after resource have been copied to classes folder" />
|
|
<element name="postprocess-output-directory"
|
|
optional="true"
|
|
description="Post-process an output folder after sources have been compiled resources have been copied. " />
|
|
<element name="finish"
|
|
optional="true"
|
|
description="Finish the build process. This can be used to take further actions, like packaging the project" />
|
|
|
|
<sequential>
|
|
|
|
<echo>
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
* * * Building project @{projectName}
|
|
* * * in workspace @{workspaceDirectory}
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
</echo>
|
|
|
|
<ant4eclipse:executeJdtProject workspaceDirectory="@{workspaceDirectory}"
|
|
projectName="@{projectName}"
|
|
prefix="buildJdtProject">
|
|
<jdtClasspathContainerArgument key="target.platform"
|
|
value="@{targetPlatformId}" />
|
|
|
|
|
|
<ant4eclipse:forProject>
|
|
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
- Step 1: Initialize
|
|
- Initialize build state, e.g. set properties or create directories.
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
<!-- template element 'intialize' -->
|
|
<initialize />
|
|
|
|
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
- Step 2: Generate-sources
|
|
- Generate any source code for inclusion in compilation.
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
|
|
<!-- template element 'generate-sources' -->
|
|
<generate-sources />
|
|
|
|
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
- Step 3: Generate-resources
|
|
- Generate resources for inclusion in the package.
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
|
|
<!-- template element 'generate-resources' -->
|
|
<generate-resources />
|
|
</ant4eclipse:forProject>
|
|
|
|
<!-- Step 4: clean output directories -->
|
|
<ant4eclipse:forEachOutputDirectory>
|
|
<echo> * Cleaning output directory '${buildJdtProject.output.directory}'</echo>
|
|
<delete dir="${buildJdtProject.output.directory}" quiet="true" />
|
|
<mkdir dir="${buildJdtProject.output.directory}" />
|
|
</ant4eclipse:forEachOutputDirectory>
|
|
|
|
<!-- Step 5: Compile the project using the eclipse java compiler (ejc) -->
|
|
<ant4eclipse:forProject>
|
|
|
|
<!-- template element 'pre-compile' -->
|
|
<pre-compile />
|
|
|
|
<echo>Compiling jdt project '${buildJdtProject.project.name}'</echo>
|
|
<echo> - source directories -> ${buildJdtProject.source.directories}</echo>
|
|
<echo> - output directories -> ${buildJdtProject.default.output.directory}</echo>
|
|
<echo> - bootclasspath -> ${buildJdtProject.boot.classpath}</echo>
|
|
<echo> - classpath -> ${buildJdtProject.classpath.absolute.compiletime}</echo>
|
|
<javac
|
|
compiler="org.ant4eclipse.ant.jdt.ecj.JDTCompilerAdapter"
|
|
source="@{sourceLevel}" target="@{targetLevel}">
|
|
<!-- let ejc read compiler settings from the project's '.settings' directory -->
|
|
<compilerarg value="compiler.options.file=${buildJdtProject.project.directory}/.settings/org.eclipse.jdt.core.prefs"
|
|
compiler="org.ant4eclipse.ant.jdt.ecj.JDTCompilerAdapter" />
|
|
|
|
<!-- Set default options if no project specific settings have been made -->
|
|
<compilerarg value="default.compiler.options.file=@{defaultCompilerOptionsFile}"
|
|
compiler="org.ant4eclipse.ant.jdt.ecj.JDTCompilerAdapter" />
|
|
|
|
<!-- Set Compiler Arguments from 'executeJdtProject' task (source folders, access restrictions) -->
|
|
<compilerarg value="compiler.args.refid=buildJdtProject.compiler.args" compiler="org.ant4eclipse.ant.jdt.ecj.JDTCompilerAdapter" />
|
|
|
|
<!-- set the source folders that are passed in from 'fromProject' -->
|
|
<src refid="buildJdtProject.source.directories.path" />
|
|
|
|
<!-- set the bootclasspath, i.e. the JRE we compile against -->
|
|
<bootclasspath refid="buildJdtProject.boot.classpath.path" />
|
|
|
|
<!-- set our compile-time classpath -->
|
|
<classpath refid="buildJdtProject.classpath.absolute.compiletime.path" />
|
|
</javac>
|
|
|
|
<!-- template element 'post-compile' -->
|
|
<post-compile />
|
|
|
|
</ant4eclipse:forProject>
|
|
|
|
<!-- Step 6: Copy resources (non-java-files) from sourcedirectories to their output directories -->
|
|
<ant4eclipse:forEachSourceDirectory>
|
|
<echo>Copying resources from directory '${buildJdtProject.source.directory}' to '${buildJdtProject.output.directory}'</echo>
|
|
<copy todir="${buildJdtProject.output.directory}">
|
|
<fileset dir="${buildJdtProject.source.directory}">
|
|
<exclude name="**/*.java" />
|
|
</fileset>
|
|
</copy>
|
|
|
|
<!-- Invoke 'post-copy-resources' template to allow customized processing -->
|
|
<post-copy-resources />
|
|
</ant4eclipse:forEachSourceDirectory>
|
|
|
|
<!-- Step 7: Post-Process output directories -->
|
|
<ant4eclipse:forEachOutputDirectory>
|
|
<postprocess-output-directory />
|
|
</ant4eclipse:forEachOutputDirectory>
|
|
|
|
<!-- Step 8: Finish build process -->
|
|
<ant4eclipse:forProject>
|
|
<!-- Invoke 'finish' template -->
|
|
<finish/>
|
|
</ant4eclipse:forProject>
|
|
</ant4eclipse:executeJdtProject>
|
|
</sequential>
|
|
</macrodef>
|
|
</project> |