« Back

Liferay Builds with the ECJ Compiler

Company Blogs March 19, 2008 By James Min Staff

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.

Threaded Replies Author Date
grrr..eclipse has been troubling me lately Ivan Cheung March 21, 2008 8:17 PM
Thanks James, Since I was force to dump my... Shepherd Ching June 5, 2008 11:30 PM

grrr..eclipse has been troubling me lately
Posted on 3/21/08 8:17 PM.
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
Posted on 6/5/08 11:30 PM.