Wednesday 8 February 2012

Tip of the Day - Eclipse Incremental compiler for Java (ECJ)

Try converting your build scripts to use the Eclipse Incremental compiler for Java (ECJ).
I found it in use within the Liferay build scripts.
ECJ, the Eclipse Compiler for Java, is an open source incremental compiler used by the Eclipse JDT. It is an option for Liferay builds and is in many cases faster than Javac or Jikes. The jar for ECJ (ecj.jar) is included in Liferay release 4.4.0 and later and more importantly in Ant 1.8.2 and upwards.
To add it to your Eclipse version of ANT add a global path setting to point to the ecj.jar, which should be where you defined the Tools.jar file to be included.
To enable ECJ in your build you have to set the compiler attribute on the javac task.
Like this:
        <javac
            classpathref="${javac.classpathref}"
            compiler="${javac.compiler}"
            debug="${javac.debug}"
...

In a LifeRay build this is set up in your build.properties as "javac.compiler=org.eclipse.jdt.core.JDTCompilerAdapter" which in turn can be detected using
<whichresource resource="/org/eclipse/jdt/core/JDTCompilerAdapter.class" property="ecj.compiler" />
So you know if you have it installed.

 

No comments:

Post a Comment