
Trunk
Note: Liferay is now using GitHub as its main source repository. The subversion repository will still be available and synchronized for some time but it is estimated that around mid 2012 it will be shut down. This page is left available because it still has useful content which is independent of subversion.
Introduction #
Liferay Portal is an open source project. This means that you can use subversion to download Liferay's main body of code (also called trunk) and to build and run Liferay using it. It's also useful if you want to fork the Liferay Portal project.
Prerequisites #
You need to install apache ant and the latest Java JDK. For Ubuntu users,
sudo apt-get install ant sun-java6-jdk
That should suffice. Alternatively OpenJDK might work, but we don't test it so if there's an OpenJDK related bug, you might get stuck! We highly recommend sun-java6-jdk. If you already have OpenJDK installed, no problem. Just install sun-java6-jdk, then run
sudo update-alternatives --config java
This will give you the option to switch default JDK to Java.
Downloading Trunk #
If you are using subversion from the command line, you can
svn checkout http://svn.liferay.com/repos/public/portal/trunk/
Credentials: guest/guest
If you are using a GUI like SmartSVN, then you have to figure out how to import a new repository into the folder of your choosing.
Directory Structure #
You should create your environment for trunk in a way that looks kind of like this.
/liferay-code /liferay-code/trunk /liferay-code/bundles
Inside trunk, you will have the source code. Inside bundles, you will have nothing, for now.
Configure Trunk #
There are configuration files that need to be set. Go into /trunk and add a file called
app.server.{your computer username}.properties
The file should contain this:
app.server.tomcat.dir={full path}/liferay-code/bundles/{tomcat folder}
Change the tomcat folder's name to the same version of tomcat that the latest GA release uses. For example, in 6.0.x, the version is tomcat-6.0.26. An example configuration would be
app.server.tomcat.dir=C:/Documents and Settings/Administrator/Desktop/liferay-code/bundles/tomcat-6.0.26
or for linux,
app.server.tomcat.dir=/home/computer-user/liferay-code/bundles/tomcat-6.0.26
Run Build Scripts #
Verify the path to your tomcat directory is correct or the build will fail (see Configure Trunk). You need to run three separate commands in this order
cd {full path}/liferay-code/trunk
ant -buildfile build-dist.xml unzip-tomcat
ant all
In the first command, you are trying to change directory to trunk. Make sure you replace {full path} with the actual path to where you put trunk. This can be C:/something for windows, or /home/something for linux.
The second command downloads Tomcat to your tomcat bundles directory, unzips it, massages it to have the correct settings, and makes it good to go. So now you'll have a tomcat server in your bundles directory in that folder you created! However, it doesn't have Liferay yet...
The third command build Liferay into the bundle. So now your Tomcat has Liferay and you can start it up to see if it works :)
Test the Build #
You are now ready to test your build, provided that "ant all" was successful.
cd {full path}/liferay-code/bundles/tomcat-{version}/bin Linux: sh catalina.sh run Windows: catalina.bat run
If Liferay starts up and is usable, you have just built a Liferay bundle from Trunk!
Coding on Trunk #
You can use
svn up
to update your trunk code to the latest source (rebase). Then you can make modifications, and to test modifications, you should run
ant deploy
to deploy your new changes to the bundle. You can also use
ant all
instead of deploy, if you want to erase all data from HSQL in your development bundle.
Troubleshooting #
If you get an error that says CATALINA_HOME environment variable isn't set, and you use linux or mac, it's because you haven't set the files as executable:
chmod -R +x {full path}/liferay-code/bundles/tomcat-{version}/bin
If that isn't enough, also do
chmod -R 0755 {full path}/liferay-code/bundles/tomcat-{version}/bin
In the case of Windows, try unchecking "read only" in the permissions for your bin folder, and apply the settings to all subdirectories and files.