We all need to earn our living ...

Your Ad Here

Friday, May 29, 2009

Building ext environment for Liferay

Some of you asked me how to create an EXT directory for Liferay.
Well, this is not that difficult but you need to pay attention to few things.

For those who do not know why an ext dir is interesting: ext directory is used to develop extension to Liferay. You can use them to develop specific configuration, plugins, configuration to your current Liferay platform.
I use it to develop extension such as portlets, but also templates and themes which are used for my projects.
It is good practice to use the ext directory and to built from it a Liferay instance in order to have all specific parameters, pictures, flash, portlets, etc. stored in a place that will not change. If you are building Liferay from SVN, you can not do so otherwise your specific parts will be deleted next time you sync with the repository.

Here is the way I proceed:

First: Liferay
I go for the SVN branche. Now I'm using 5.2.x branch which is the current stable version of Liferay. 5.3.x is pointing out, but still under heavy development and not stable enough to use it as a production or development platform.

Second: Glassfish
I'm using Glassfish 2.1. Just download it from Glassfish web site (download the right bin according to you Operating System).
Then, remember path to it, you will need it later.

Third: Configuring the whole things to get the ext dir
So, now that we have Liferay and Glassfish let's do some configuration.

First, place the right jar libraries at the right place (see here for some explanation on how to do under os x)

Second, go to your Liferay directory and find the following configuration files: app.server.properties and release.properties.

In app.server.properties make sure that Glassfish is selected as your Application Server and that all other application servers are commented out by a #
Then, hard code (or if you are smarter used env variable to do it) path to your Glassfish server. You should have it there: app.server.parent.dir=PATH/TO/YOUR/GLASSFISH/SERVER
example:
let's say your glassfish is under Jhon Doe accoung (jdoe) on OS X:
/Users/jdoe/Documents/JavaProjets/glassfish then you should have the following line in your app.server.properties file:
app.server.parent.dir=/Users/jdoe/Documents/JavaProjets

Make sure that there is no trailing / and that the last directory it the one containing your Glassfish directory as seen in the example just above.

End by saving this file as app.server.username.properties where username is your username as used to log into your computer.
According to the example just above the file should be saved under app.server.jdoe.properties

Now that Liferay is properly configured I suggest a test run before going further and building the ext directory.
So just go to your Liferay directory and enter the following command:

ant start

ant compile

ant deploy

then go to you Glassfish bin dir and make it rock and roll: asadmin start-domain
If nothing come to your display, check your Glassfish logs for error.

If you have a running Liferay, you are free to proceed to the next step and start building your ext directory.

Go to your release.properties file in Liferay and check that you have the following lines:

##
## Extension Environment
##

lp.ext.dir=${project.dir}/../ext

According to your operating system you will have to change / in to \ (\ is for Windows, while OS X, Linux, Solaris will use / as path separator)

Should you have to save changes to this file, remember to name it release.username.properties (according to example you it will be release.jdoe.properties)

Then launch a ant build-ext command and you will have just above your Liferay dir the ext dir you are expecting.
Just go to that directory and make sure app.server.properties is poiting to the right Application Server (here Glassfish) as mentioned above.
For the same reason it is good to save changes in app.server.username.properties

Fourth: this is your time. Just play with it
From here you a free to go alone and play with your freshly build ext directory.

Remember that in order to get it work you'll have to run ant deploy from the ext dir. This will deploy your Liferay instance with all its specific parts.

0 commentaires: