Liferay: Líder no Quadrante Mágico da Gartner pelo sexto ano consecutivo! Leia mais aqui

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.

0 Anexos
75106 Visualizações
Média (5 Votos)
A média da avaliação é 5.0 estrelas de 5.
Comentários
Respostas do tópico Autor Data
Thank you for this entry, the final step to... Gunnar Brinkmann 19 de Setembro de 2012 01:44
Great article! You saved me a lot of work,... Juanjo Hernández Cánovas 27 de Novembro de 2012 08:33
Thanks. Habib Zare 2 de Março de 2013 08:48
Great. Solve my problem. Diego Santiviago 21 de Outubro de 2013 14:29
Ta-Da!! That solved my problem! I've just added... Raja Datla 7 de Outubro de 2014 01:44

Thank you for this entry, the final step to resolve my problems regarding theme development / deployment (first step: don't let Eclipse deploy themes, use ant tasks)
Postado em 19/09/12 01:44.
Great article! You saved me a lot of work, Thank you.
Postado em 27/11/12 08:33.
Postado em 02/03/13 08:48.
Great. Solve my problem.
Postado em 21/10/13 14:29.
Ta-Da!! That solved my problem! I've just added the ecj.har in Ant run time on Eclipse and that solved my problem. I don't have to do anything else.

FYI - This is JbossAs7 + Liferay 6.1.1
Postado em 07/10/14 01:44.