Getting started as a Liferay Developer in a few steps

This Wiki page aims to collect all the necessary information to get started as a Liferay Core Developer from scratch in a few steps. For every step you will find links to more detailed information.

Get your Credentials #

If you are going to contribute your code to Liferay, you must first go through these steps in order to gain the required credentials. Otherwise, skip this point.

Liferay #

Register at liferay.com (Register link is on the dockbar in the upper right corner) to become a part of the developer community by participating in forums, updating wiki articles and more. Don't forget reading our code http://www.liferay.com/community/wiki/-/wiki/Main/Liferay+development+style.

JIRA #

JIRA is a bug-tracking system developed by Atlassian. It is used by Liferay to accept and also to process bug tickets. You will need a JIRA account to file or update an issue.

In our Wiki you can find more information about JIRA.

Github #

In order to checkout and commit changes from Liferay master repository, you need a Github authorized account. To setup the required tools, just follow Github online help.

Install Minimal Required Tools #

The minimal requirements for developing Liferay code are Java Development Kit (JDK) and Ant. You can get the right version for your OS and CPU architecture here:

Once you have installed these tools, you have to create the environment variables JAVA_HOME and ANT_HOME pointing to the installation path of JDK and ANT, respectively. Finally, include their respective bin folder (JAVA_HOME/bin, ANT_HOME/bin) in your OS PATH environment variable. To check if your installation is going well so far, open a command prompt and type:

java -version 

ant -version 

NOTES:

  • Make sure $JAVA_HOME and $ANT_HOME do not contain any space character in their paths.
  • Define ANT_OPTS environment variable to prevent running out of memory when building large projects.

Install and Build Liferay Portal Code #

In this step we will complete a basic development environment by downloading and building Liferay source code.

Create a Local Root Directory for Liferay Source Code #

Having a tidy local directory structure for the source code is MUST. It saves lot of time and prevents errors when adding new projects. First you have to create somewhere in your local environment a folder to be used as root of all Liferay source code. From now on we will refer to this folder as ${liferay-dev-home}.

TIP: Make the path to ${liferay-dev-home} as clean and short as possible.

Checkout Liferay Source #

There are two options to obtain Liferay source code:

Try to organise the folder structure for the source code under your ${liferay-dev-home} directory so that the different Liferay projects and versions are easy to work with. One possible folder structure might be:

For master:

${liferay-dev-home}/master
${liferay-dev-home}/master/portal
${liferay-dev-home}/master/plugins
...

For versions:

${liferay-dev-home}/${liferay-version}/
${liferay-dev-home}/${liferay-version}/portal
${liferay-dev-home}/${liferay-version}/plugins
...

For example if you are working with the latest development version and the 6.2 maintenance branch your directory structure would look like this:

${liferay-dev-home}/
   master/
      portal
      plugins
      ...
   6.2.x/
      portal
      plugins
      ...

For a more in-depth look at setting up Git and using GitHub to contribute to Liferay, see the wiki article Contribute using Git and GitHub

Install a Liferay Bundle #

You can download the desired liferay bundle from SourceForge or execute the following ant task (example for Tomcat). Note that this task works out of the box if you have the suggested directory structure. Otherwise you will need to make some changes to it (or mimic it with symbolic links).

ant -buildfile build-dist.xml unzip-tomcat

This will add to your project structure a /bundles folder containing the tomcat server.

Build Liferay Portal #

We will now build the Liferay Portal project and deploy it in the application server installed in the previous step. Liferay provides a set of ant tasks to make this automatic.

These tasks use the portal/build.properties and portal/app.server.properties files to determine how and where the project will be built and deployed. If you need to change this configuration, do not edit the default files but instead copy them, rename them (e.g app.server.${USER}.properties) and edit whatever lines you need.

Finally, execute the following ant task:

ant all

You may also need to create your own build.${USER}.properties file in your plugins project root folder before deploying plugins in the application server.

Known issues #

If you get this error:

out of memory error: java heap space

make sure you have set ANT_OPTS as explained here: Ant opts.

If you get any errors while deploying plugins, go through Plugin Deployment Troubleshooting.

Configure a Database #

Though liferay includes a default HSQL database, it is recommendable to install and configure a more powerful one for your tests. You can find more details here: Database Configuration

Start Liferay Portal #

Now start your bundle. For a Tomcat bundle and a UNIX environment, execute:

./startup.sh

at the ${liferay-dev-home}/master/bundles/${tomcat-version}/bin directory.

Then browse http://localhost:8080. If everything has gone well, you should reach the Liferay Portal login page. Enter test@liferay.com for user and test for password.

Install and Setup an Integrated Development Environment (IDE) #

As we have seen so far, JDK and ant are all we need to build and run Liferay code. Nevertheless it's recommended to install an Integrated Development Environment (IDE) to make the programming tasks easier.

Basic IDE Installation #

You will find a selection of IDEs and their links on how to install and configure them in this wiki page: Integrated Development Environments

Optimal Core Development Environments #

Once you have installed the basics of your Liferay development environment, you may want to follow these instructions to setup a fully-optimized Liferay core development environment:

Additional Resources #

0 Attachments
33392 Views
Average (5 Votes)
The average rating is 5.0 stars out of 5.
Comments
Threaded Replies Author Date
Hi there thanks for this tutorial on how to... Oussama Denden December 27, 2012 1:41 AM

Hi there
thanks for this tutorial on how to Get started as a Liferay Developer
I followed it and i was able to build Liferay and run it i have some remarks though
1-i didn't change any properties folder all i have done is creating the folder structure u mentioned including the bundle folder
2-Install a Liferay Bundle before installing liferay it self so it would be
ant -buildfile build-dist.xml unzip-tomcat
ant all
then go to tomcat bin folder and run it on windows it would be something like this
startup.bat
thanks again
Posted on 12/27/12 1:41 AM.