
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.
Then add ecj.jar to:
Eclipse Preferences->Ant->Runtime->Classpath->Ant Home Entries
Tricks for linux #
In the wiki article "Development Environment (Ubuntu Linux)" there is a section on how to do this in an alternative way. Here it is:
You can use the ECJ compiler with Eclipse instead of Jikes. It greatly improves build and compile performance, and cuts your time by anywhere from several seconds to up to half.
Install ECJ:
sudo apt-get install ecj-bootstrap
Find ECJ:
which ecj
You'll probably get something like /usr/bin/ecj
Find Jikes:
which jikes
You'll probably get something like /usr/bin/jikes
Create a $HOME/bin directory:
sudo mkdir $HOME/bin
Create a symbolic link that points Jikes to ECJ:
sudo ln -s /usr/bin/ecj $HOME/bin/jikes
Add it to the PATH by adding this line in $HOME/.bashrc :
export PATH=$HOME/bin:$PATH
Make sure you reload your .bashrc :
cd $HOME . .bashrc
Or just logout and login again.
Find the new "Jikes":
which jikes
Should give you something like: /home/username/bin/jikes
Try Jikes at the prompt to check that it is actually calling ECJ:
Eclipse Java Compiler v_677_R32x, 3.2.1 release Copyright IBM Corp 2000, 2006. All rights reserved.
This is just an alternative if you are on linux and do not want to install or do not have the jar, or would rather not use the build properties modifications.