Ant4Eclipse provides it's own compiler adapter that allows you to use the eclipse compiler for Java (ECJ) within the ant <javac>
task.
Using the ECJ has many advantages over using the standard javac from the underlying JDK:
To enable the ECJ, you have to set the Ant4Eclipse ECJ compiler adapter. This can be done by either setting the global build.compiler
property, which will affect all <javac>
tasks throughout the build, or by setting the compiler attribute, specific to the current <javac>
task. The value to enable the Ant4Eclipse EcjCompilerAdapter is org.ant4eclipse.jdt.ecj.EcjCompilerAdapter
.
The following example shows how to enable the Ant4Eclipse ECJ compiler adapter:
<javac destdir="${default.output.directory}" compiler="org.ant4eclipse.jdt.ecj.EcjCompilerAdapter" > ... </javac>
Alternatively you can make use of the jdtCompiler
which is just an extension of the javac
task simply allowing to switch between the javac
and ecj
compiler backend.
The following example shows how to enable the Ant4Eclipse ECJ compiler adapter:
<jdtCompiler destdir="${default.output.directory}" useecj="true"> ... </jdtCompiler>
The compiler options can be set in several ways.
javac
attributesTHe JDT compiler options file can be found at
workspace\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.core.prefs
or
project\.settings\org.eclipse.jdt.core.prefs
. You can set the compiler option files using the compilerarg
element:
<javac destdir="${buildPlugin.default.output.directory}" compiler="org.ant4eclipse.jdt.ecj.EcjCompilerAdapter" > ... <compilerarg value="compiler.options.file=my/project/path/.settings/org.eclipse.jdt.core.prefs" compiler="org.ant4eclipse.jdt.ecj.EcjCompilerAdapter" /> </javac>
<javac destdir="${buildPlugin.default.output.directory}" compiler="org.ant4eclipse.jdt.ecj.EcjCompilerAdapter" > ... <compilerarg value="default.compiler.options.file=my/path/org.eclipse.jdt.core.prefs" compiler="org.ant4eclipse.jdt.ecj.EcjCompilerAdapter" /> </javac>
<javac destdir="${default.output.directory}" compiler="org.ant4eclipse.jdt.ecj.EcjCompilerAdapter" > <src refid="source.directories.path" /> <bootclasspath refid="boot.classpath.path" /> <classpath refid="classpath.absolute.compiletime.path" /> </javac>