Liferay Builds with the ECJ Compiler

I just made a Wiki on how to configure ECJ for your Liferay builds. It is here, but I'll just paste the most important parts:

 

Liferay Builds with ECJ

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 is included in Liferay release 4.4.0 and later.

Configure the build to use ECJ

In release 4.4.0 and later the build.properties file can be modified so ECJ can be used for builds. Simply changing this property is all you need to do, as the jar file for ECJ is included in the release. Here is an example from the build file of release 4.4.2:

    ##
    ## Compiler
    ##
    
    javac.compiler=modern
    #javac.compiler=org.eclipse.jdt.core.JDTCompilerAdapter


Simple uncomment the line, using a build.{user name}.properties file, that uses the JDTCOmpilerAdapter

After doing this, you will get an initial build error message:

  Task cannot continue because ECJ is not installed.
  
  ECJ was automatically installed. Please rerun your task.

This is expected. It has installed the ECJ jar file into your Ant lib directory. Simply rerun your Ant build.

 

 

Configure Eclipse IDE to use ECJ

Even though you're using Eclipse, you're using Ant to build Liferay and Liferay's build is not dependent on ECJ. After changing the build property, if You keep getting the error message:

  Task cannot continue because ECJ is not installed.
  
  ECJ was automatically installed. Please rerun your task.

 

Do not fear, you simply need to put the ecj.jar file into the lib directory of the Ant plugin directory in your Eclipse install. For example, in my linux install, this directory is:

    /opt/eclipse/plugins/org.apache.ant_1.7.0.v200706080842/lib


Copy the ecj.jar file from the similar lib directory from your Ant install.

Blogs
Thanks James,

Since I was force to dump my beloved jikes, I have seeked a new one for a long time.

I don't use Eclipse IDE environment, Ubuntu provides ecj compiler separately:

Step 1: sudo apt-get install ecj

Step 2: If you using ant 1.7.0 of Ubuntu (sudo apt-get install ant)
You need to link ecj.jar to its directory:
sudo ln -s /usr/share/java/ecj.jar /usr/share/ant/lib/ecj.jar