
Building Liferay distribution files
Alternative Languages: 日本語
Table of Contents [-]
- Introduction
- Steps to build a distribution bundle
- Make directory structure for the //portal// and //plugins//
- Download official Apache Tomcat distribution file from tomcat.apache.org
- Check out source from SVN
- Make a build.properties for //plugins// that fits your needs
- Make a build.properties, app.server.properties and release.properties for //portal// that fits your needs
- Edit build-dist.xml in the root of the //portal// directory
- Build Liferay distribution
- You are almost done
- Extract Ext environment and deploy to your Tomcat directory
- Start Liferay
- Notes
- Explanation of directory structure /development/liferay/liferay_svn
- Building distributions other than Tomcat-6.0
- Make directory structure for the //portal// and //plugins//
This article needs updating. For more information, see Wiki - Need Updating. Liferay now provides Nightly Builds as well.
Introduction #
This article describes how to build Liferay from the development trunk.
This article tries to give a description on how to build your own distribution file, similar to the one you download from the Liferay web site. Currently, the article only covers the Tomcat 6.0.x bundle, but it can be extended to cover other application servers.
Steps to build a distribution bundle #
Make directory structure for the //portal// and //plugins// #
- mkdir /development/liferay/liferay_svn
- mkdir /development/liferay/liferay_svn/output
- mkdir /development/liferay/liferay_svn/output/5.1.x
- mkdir /development/liferay/liferay_svn/output/5.2.x
- mkdir /development/liferay/liferay_svn/output/bundles-5.1.x
- mkdir /development/liferay/liferay_svn/output/bundles-5.2.x
- mkdir /development/liferay/liferay_svn/plugins
Download official Apache Tomcat distribution file from tomcat.apache.org #
Note that you have to download the zip file even if you are running on Linux. This is a pity, since with the zip file, you will have MS-DOS line endings in Tomcat config files, since the zipfile is meant for MS-DOS / Windows. Ideally, Liferay should make liferay tomcat tar.gz bundles, which we could use on Unix.
I downloaded apache-tomcat-6.0.18.zip and placed it in output/bundles-5.2.x/ directory. Then I had to extract the zip file, which resulted in a apache-tomcat-6.0.18 directory, and removed the original apache-tomcat-6.0.18.zip.
Then I renamed this directory to just tomcat-6.0.18, since that is what Liferay uses in its property files. I am pretty sure that Liferay are doing some modifications to the tomcat directory at this time.
What I did, was to remove all the content from the webapps directory, and copy the "bin/setenv.sh" from an official Tomcat bundle to the bin directory. You should also edit the conf/server.xml, by adding the URIEncoding attribute to the <Connector port="8080" and <Connector port="8009" elements. Finally, I zipped up this tomcat-6.0.18 directory in a tomcat-6.0.18.zip file using zip -r tomcat-6.0.18.zip tomcat-6.0.18
I am a bit unsure if Liferay makes other changes to the stock Apache Tomcat zip content.
Check out source from SVN #
Changes to anonymous access to Liferay's SVN UPDATED 09/03/09
The links should contain svn: followed by two slashes, but I could not figure out how to place them correctly.
- cd /development/liferay/liferay_svn
- svn checkout svn://svn.liferay.com/repos/public/portal/branches/5.2.x/ (if you want to build dist for this branch)
- svn checkout svn://svn.liferay.com/repos/public/portal/branches/5.1.x/ (if you want to build dist for this branch)
- svn checkout svn://svn.liferay.com/repos/public/portal/trunk/ (if you want to build dist for this branch)
- cd /development/liferay/liferay_svn/plugins
- svn checkout svn://svn.liferay.com/repos/public/plugins/trunk (if you want to build dist for trunk / 5.2.x branch)
- svn checkout svn://svn.liferay.com/repos/public/plugins/branches/5.1.x (if you want to build dist for this branch)
Note that currenlty it seems like the trunk of the plugins should be used with the 5.2.x branch for portal, since there are no such branch for plugins. You only have to check out branch 5.1.x or 5.2.x if you are going to do a build for those branches.
Make a build.properties for //plugins// that fits your needs #
(For example in /development/liferay/liferay_svn/plugins/trunk directory, if you are working with trunk) In the root directory of plugins, make a copy of build.properties, and name it build<username>.properties. Update the settings corresponding to your app server in directory layout Here is my setting
build.alf.properties file:
app.server.dir=${project.dir}/../../output/bundles-5.2.x/tomcat-6.0.18 app.server.classes.portal.dir=${app.server.portal.dir}/WEB-INF/classes app.server.lib.global.dir=${app.server.dir}/lib/ext app.server.lib.portal.dir=${app.server.portal.dir}/WEB-INF/lib app.server.portal.dir=${app.server.dir}/webapps/ROOT javac.memoryMaximumSize=1600m
Make a build.properties, app.server.properties and release.properties for //portal// that fits your needs #
(For example in /development/liferay/liferay_svn/5.2.x if you are working on 5.2.x branch) In the root directory of "plugins", make a copy of app.server.properties, and name it app.server.<username>.properties. In the root directory of "plugins", make a copy of build.properties, and name it build.<username>.properties. In the root directory of "plugins", make a copy of release.properties, and name it release.<username>.properties. Update the settings corresponding to your app server directory layout and build layout.
app.server.alf.properties :
app.server.type=tomcat app.server.parent.dir=${project.dir}/../output/bundles-5.2.x app.server.tomcat.version=6.0 app.server.tomcat.dir=${app.server.parent.dir}/tomcat-6.0.18 app.server.tomcat.classes.global.dir=${app.server.tomcat.dir}/lib app.server.tomcat.lib.endorsed.dir=${app.server.tomcat.dir}/lib/ext app.server.tomcat.lib.global.dir=${app.server.tomcat.dir}/lib/ext app.server.tomcat.lib.support.dir=${app.server.tomcat.dir}/lib/ext app.server.tomcat.support.dir=${app.server.tomcat.dir}/lib/ext app.server.tomcat.zip.name=liferay-portal-tomcat-6.0-${downloads.version}.zip
build.alf.properties :
javac.memoryMaximumSize=1600m
release.alf.properties :
lp.version=5.2.0 lp.source.dir=${project.dir}/../output/5.2.x/source lp.ext.dir=${project.dir}/../output/5.2.x/ext lp.plugins.dir=${project.dir}/../plugins/trunk
Edit build-dist.xml in the root of the //portal// directory #
The dist target in this build file will build the distribution for all bundles (Tomcat, JBoss and so on). You probably just want one bundle, so you should edit the build-dist.xml file to suit your needs. Here are the modified sections of my build-dist.xml file : Here I have updated the app.server.tomcat.dir setting to point to my Tomcat version
<target name="build-dist-tomcat-6.0"> ...... app.server.tomcat.version=6.0 app.server.tomcat.dir=${app.server.parent.dir}/tomcat-6.0.18
Here I have removed the hardcoded tomcat version numbers, and use the property settings instead. I have filed LPS-897 to suggest that Liferay makes the same change
<target name="zip-tomcat-6.0"> <delete file="dist/liferay-portal-tomcat-6.0-${lp.version}.zip" failonerror="false" /> <antcall target="deploy-default-theme"> <param name="deployer.dest.dir" value="${app.server.tomcat.deploy.dir}" /> <param name="deployer.app.server.type" value="tomcat" /> </antcall> <antcall target="zip-executable"> <param name="zip.executable.file" value="liferay-portal-tomcat-6.0" /> <param name="zip.executable.dir" value="${app.server.tomcat.dir}" /> </antcall> </target>
Here I have taken away the syncing from subversion, the building and zipping of the other bundles except Tomcat, the extraction of the plugins sdk, the zipping of the source code, and the copying of the resulting distribution builds :
<target name="dist"> <antcall target="all" /> <delete dir="${lp.plugins.dir}/dist" /> <ant dir="${lp.plugins.dir}/themes/liferay-jedi-theme" target="war" inheritAll="false" /> <antcall target="java2html" /> <antcall target="dtddoc" /> <delete dir="dist" /> <mkdir dir="dist" /> <antcall target="zip-portal-war" /> <antcall target="build-dist-tomcat-6.0" /> <delete dir="${lp.ext.dir}" /> <antcall target="build-ext" /> <antcall target="zip-api" /> <antcall target="zip-ext" /> <antcall target="zip-sql" /> <antcall target="zip-tomcat-6.0" /> <copy file="tunnel-web/tunnel-web.war" tofile="dist/liferay-portal-tunnel-web-${lp.version}.war" /> </target>
Build Liferay distribution #
Run the dist target in the build-dist.xml Ant file in the root of Liferay portal. This takes about 10 minutes on my pc. Everything that has been built is in the /development/liferay/liferay_svn/5.2.x/dist directory.
You are almost done #
You now have your own bundle zip. But this bundle does not contain the actual Liferay web application, which is part of the bundlezip you download from Liferay / SourceForge web sites.
Extract Ext environment and deploy to your Tomcat directory #
Unzip the tomcat zip bundle, and unzip the Liferay extension environment which you have built, they are both present in the /development/liferay/liferay_svn/5.2.x/dist directory. In the Liferay extension environment, make your own app.server.<username>, with settings pointing to your unzipped Liferay bundle. Now run the deploy Ant target in the Ext environment, and the Liferay web application is deployed to your Tomcat directory. You could not zip your Tomcat directory, and you would then have a zip bundle that is similar to the one you download from Liferay. I do not fully comprehend why this manual step is necessary, and why the build-dist.xml target seems to create a Tomcat zip bundle that is fairly empty, i.e. missing the Liferay web application itself.
Start Liferay #
You can now start Liferay in your Tomcat bundle, and you have a fully working and running version of Liferay.
Notes #
- app.server.<username>.properties gets deleted
- Note that in the "build-dist-tomcat-6.0 target in the build-dist.xml, your app.server.<username>.properties file gets deleted. So when you try to do another build, that file is missing, so you should recreate it before running the "dist" target in "build-dist.xml" again. Maybe I am missing something here, maybe we should not use an "app.server.<username>.properties file.
Explanation of directory structure /development/liferay/liferay_svn #
- 5.1.x (this is the svn checkout of the portal 5.1.x branch)
- 5.2.x (this is the svn checkout of the portal 5.2.x branch)
- output/5.2.x (this is build output for the portal 5.2.x branch)
- output/5.2.x/ext (this is build of the extension environment for the portal 5.2.x branch)
- output/bundles-5.2.x (this is where I want my bundles to be placed)
- output/bundles-5.2.x/tomcat-6.0.18 (this is the download apache tar.gz file extracted, and which is used by Liferay to build the distribution for Tomcat)
- plugins/5.1.x
- plugins/trunk
- trunk (this is the svn checkout of the portal trunk)
Building distributions other than Tomcat-6.0 #
You should be able to follow the same description as above, but you probably have to download and extract the application server in the same manner as for Tomcat, and point the properties files to the correct path, and edit the build-dist to build your exact configuration.