« Torna a Ext Plugin

Setting up the Extension Environment

This article explains how to set up an Extension Environment that allows you to customize Liferay for your own purposes, but allows to easily upgrade to future releases of Liferay.

Two popular development environments are the Eclipse IDE and Netbeans IDE.

Requirements #

  • Java 5.0+
  • Ant 1.8 or later
  • SVN client (TortoiseSVN, kdesvn, SmartSVN, command line tool or an integrated IDE that supports SVN).
  • Liferay Portal source code
  • Web Server (Tomcat, Resin, etc.)

Set up #

Set JAVA_HOME to your Java directory. Set ANT_HOME to your Ant directory. Add JAVA_HOME\bin and ANT_HOME\bin to System Path.

Building and deploying #

First make your base Liferay directory (ex: c:\Liferay). From now on, we will call this directory {Liferay}.

Unzip the portal source code to {Liferay}\portal.

Configuring your application server properties#

Documentation warning: The documentation says that the application server properties should be configured after doing the ant build (ant start), but the ant build will fail if the app server properties are not set beforehand.

Copy the file app.server.properties, located in {Liferay}/portal, to app.server.{user name}.properties file in the same directory, where {user name} is your system login name.

 cp app.server.properties app.server.$(whoami).properties

The default application server is Tomcat-5.5, as indicated by the app.server.type property. You may select a different server type. According to the server selected, set the corresponding directory. For instance, for Tomcat you may set the property as follows: app.server.tomcat.dir=c:/portal/tomcat

Configuring your compiler#

In Liferay-5 the default Java compiler is the Sun Java compiler, because in Liferay 5 and higher development was switched to JDK 5. In older versions, the Jikes compiler is assumed to be the default. If you plan to use the Jikes compiler, be aware that different JDK versions require different versions of Jikes. Please see the Jikes article for more details. To use the Sun Java compiler, set the javac.compiler property in {Liferay}/portal/build.properties to modern.

Copy the file build.properties, to build.{user name}.properties file in the same directory, where {user name} is your system login name.

 cp build.properties build.$(whoami).properties

In this file you will notice that, by default, the javac.fork property is set to true. If set to false, this may lead to java.lang.OutOfMemoryError: Java heap space while building, even if your system has lots of free memory. To fix this, set javac.fork=true and make sure javac.memoryMaximumSize is large enough (the default 512m should do fine).

Ant build#

To build liferay go to {Liferay}\portal and execute:

 ant clean start 

The start target will build all the modules in the appropriate order to make sure everything goes ok. You should run this target every time there are changes to code inside portal\. This includes when you make changes or when you update some changes from the Subversion repository.

Unzip Tomcat bundle to {Liferay}\tomcat if you do not already have tomcat installed.

Configuring the release properties for ext environment#

Go to {Liferay}\portal and create a release.{user name}.properties file, where {user name} is your system login name. Be aware that the user name is case sensitive, even in Windows.

Add the line: lp.ext.dir={Liferay}/portal/ext

On nix systems, the following command will do this, once you are in {Liferay}\portal

  echo "lp.ext.dir=$(pwd)/ext" > release.$(whoami).properties

This directory may not yet exist if you are building the Extension Environment for the first time. You will notice that this property is a full path and may look like D:/Projects/liferay/portal/ext. Linux users can also set the property to a relative path like: lp.ext.dir=ext.

Execute the following from {Liferay}\portal:

 ant build-ext

Verify that EXT Environment is being built in your {Liferay}/portal/ext.

Move or copy the following properties files to the extension environment: {Liferay}\portal\ext.

  • {Liferay}\portal\build.{user name}.properties (Document error??? There is no "build.{user name}.properties" you can copy/move from. If you copied the build.properties to {Liferay}\portal\ext, you would not be able to deploy the ext. I assume the author means "release.{user name}.properties"?)
  • {Liferay}\portal\app.server.{user name}.properties

Developing #

You are now ready to use the EXT environment to customize Liferay. Do not write portlets in the EXT environment if you can possibly avoid it. Use the Plugins SDK instead.

It is advised to never modify core Liferay source code directly, but instead copy the code to the extension environment. This is to prevent conflicts from future upgrades, as well as keeping a backup of core code.

If you wish to change some of Liferay's code, copy the directory structure into the extension environment. For example, the bookmark portlet is in: {Liferay}/portal/portal-impl/src/com/liferay/portlet/bookmarks. To change this code, copy the file to {Liferay}/portal/ext/ext-impl/src/com/liferay/portlet/bookmarks and edit away!.

Note for Liferay 4.2: In Liferay 4.2 portal-impl is named portal-ejb and ext-impl is ext-ejb

To deploy to web server, run the following from {Liferay}/portal/ext:

 ant deploy

Notes (for Tomcat 5.5 and Liferay 4.3.1) #

The "ant deploy" does not copy {Liferay}/ext/servers/conf/Catalina/localhost/ROOT.xml to the Tomcat directory. You'll need to edit this file to define your datasource and manually copy it to the Tomcat server at {Tomcat}/conf/Catalina/localhost/ROOT.xml.

Also, the jars copied to {Tomcat}/common/lib/ext do not get picked up since Tomcat does not include the 'ext' directory in its classloader definitions (see {Tomcat}/conf/catalina.properties). To solve this, you can symlink or copy all the jars in {Tomcat}/common/lib/ext to {Tomcat}/common/lib. Or edit the {Tomcat}/conf/catalina.properties and add {Tomcat}/common/lib/ext/.jar to the 'common.loader' path.

Related Articles #

Jikes

Ant opts

Getting set up

Deploying an EXT WAR file

0 Allegati
69224 Visualizzazioni
Media (2 Voti)
La media del punteggio è 4.5 stelle su 5.
Commenti
Commenti Autore Data
You guys need to look over and update these... Secret Developer 22 settembre 2009 6.11
I'm using liferay 5.2.3 with jdk 1.6 and tomcat... Rasheed Abdur Muhammad 14 ottobre 2009 7.29
I would advice new bees to look at this ... Raja Nagendra Kumar 24 settembre 2009 22.25
i already post how to setup ext environment in... yan sakhrul hadian 4 gennaio 2010 23.40
Hi, Have any one tried to configure liferay on... DarshanKumar N Bhatia 26 aprile 2010 21.57
We are trying to modify the CreateAccountAction... Marco Peters 5 maggio 2010 3.08
if some else is experiencing this problem, here... Marco Peters 5 maggio 2010 23.51
I just like to point out that this document is... Ali Shahrami 10 giugno 2010 17.10
It makes no sense to have comments on a wiki! ... Tim McGuire 7 luglio 2010 11.27

You guys need to look over and update these pages. Very bad documentation.

Move or copy the following properties files to the extension environment: {Liferay}\portal\ext.

* {Liferay}\portal\build.{user name}.properties (Document error??? There is no "build.{user name}.properties" you can copy/move from. If you copied the build.properties to {Liferay}\portal\ext, you would not be able to deploy the ext. I assume the author means "release.{user name}.properties"?)
* {Liferay}\portal\app.server.{user name}.properties


What is this?? There is a build.username.properties file. You are not helping, but confusing people...
Inviato il 22/09/09 6.11.
I would advice new bees to look at this

http://docs.liferay.com/portal/4.3/official/liferay-extension-environment-gu­ide-4.3.pdf

it has details on the significance of portal-ext and other extension environment properties.

Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com
Inviato il 24/09/09 22.25.
I'm using liferay 5.2.3 with jdk 1.6 and tomcat 6.
ant build-ext task did not copied "build.{user name}.properties",
app.server.{user name}.properties and release.{user name}.properties
files in ext folder and I have to manually copied those files.
Inviato il 14/10/09 7.29 in risposta a Baris Sener.
i already post how to setup ext environment in liferay 5.2.3 and mysql
please visit http://learn4share.blogspot.com or http://sakhrul.blogspot.com
Inviato il 04/01/10 23.40.
Hi,
Have any one tried to configure liferay on sun java application server.
Let me Know.
Inviato il 26/04/10 21.57.
We are trying to modify the CreateAccountAction by copying it into {Liferay}\portal\ext\ext-impl\src\com\liferay\portlet\login\action\ and editing it. However, running ant deploy fails with compile errors; obviously the needed libs (global, {Liferay}\portal\ext\lib\global) are not on the classpath:

C:\liferay\portal\ext\ext-impl\src\com\liferay\portlet\login\action\CreateAccoun­tAction.java:56: package com
.liferay.portal.service.impl does not exist
import com.liferay.portal.service.impl.UserServiceImpl;
^

What are we doing wrong here?
Thanks in advance, Marco
Inviato il 05/05/10 3.08.
if some else is experiencing this problem, here is the soloution:
https://www.liferay.com/community/forums/-/message_boards/message/2523­737
Inviato il 05/05/10 23.51 in risposta a Marco Peters.
I just like to point out that this document is for LR 5.2.x and if you happen to get the source code from LR SVN trunk you have downloaded LR 6.0 and the extension setup could be different.
Inviato il 10/06/10 17.10 in risposta a Marco Peters.
It makes no sense to have comments on a wiki! The point of a wiki is to have collaboratively upgraded information. Having comments means that I have to read the wiki article and then the comments to make sure nobody found an error and didn't bother fixing it.
So, if you find the wiki lacking, then edit it! If you have a question, post it to the forums. If you have a link you think might be helpful, post it in the article. Liferay documentation is scattered and outdated enough without comments on a wiki for crying out loud.
Inviato il 07/07/10 11.27.