Liferay 6.0 Development on Ubuntu Lucid 10.04

Liferay 6.0 Development on Ubuntu Lucid 10.04 #

This article describes what is needed to set up a development environment for Liferay Portal.

/home/{username}/opt and /home/{username}/workspace will be the paths used for eclipse and its workspace

Many of the dependencies for Liferay development reside in the Ubuntu software repository. Eclipse also exists in the repository but is out of date.

Dependences for Liferay Development #

The following tools are needed to develop for Liferay:

  • Apache Ant
  • Open JDK 6.0
  • Eclipse for Java EE
  • Subversion
  • Liferay IDE

Install Ant, MySQL, Subversion and OpenJDK on Ubuntu by doing the following from a command prompt:

sudo apt-get update
sudo apt-get install ant openjdk-6-jdk libnb-svnclientadapter-java
  • Download Eclipse from here: http://www.eclipse.org/downloads/
  • Choose the Eclipse IDE for Java EE Developers option.
  • Extract Eclipse to /home/{username}/opt
  • Launch Eclipse and set the workspace to /home/{username}/workspace

Subclipse #

Configure Eclipse to find JavaHL for Subversion by modifying /home/{username}/opt/eclipse/eclipse.ini as follows:

-vmargs
-Djava.library.path=/usr/lib/jni

Install Subclipse by doing the following:

Expand Subclipse and select the following components:

  • Subclipse
  • Subversion Client Adapter (Required)
  • Subversion JavaHL Native Library Adapter (Required)

Restart Eclipse

Check Subversion JavaHL by going to Window > Preferences > Team > SVN.

Make sure JavaHL (JNI) appears in the SVN interface section.

Define the Liferay Subversion repository in Eclipse by doing the following:

  • Switch to the SVN Repository Exploring in Eclipse
  • Right-click in SVN repositories pane and click New > Repository Location
  • Enter the following in the Url box:
    svn://svn.liferay.com/repos/public
  • Enter Guest as the username.

Extract Liferay components #

The Liferay components are made up of 3 different components:

  • Liferay Tomcat Bundle
  • Liferay Portal Source
  • Liferay Plugins SDK

Download Liferay from here: http://sourceforge.net/projects/lportal/files/

  • liferay-portal-tomcat-6.0.2.zip
  • liferay-portal-src-6.0.2.zip
  • liferay-plugins-sdk-6.0.2.zip

Liferay Tomcat Bundle #

The Liferay Tomcat Bundle is a fully functional Liferay Portal server pre-configured on Tomcat 6.0.

  • Create a directory called bundles in the Eclipse workspace: /home/{username}/workspace/bundles
  • Extract the Liferay Tomcat Bundle in the newly created bundles directory in the Eclipse workspace

Liferay Portal Source #

The Liferay Portal Source is the source code for Liferay itself. The Liferay Source code serves as a guide to Liferay customizations for Hook Plugins or Extension Plugins.

  • Extract the Liferay Portal Source to /home/{username}/workspace

Liferay Plugins SDK #

The Plugins SDK is used by the Liferay IDE in the background. The reason for this is because the Plugins SDK is IDE agnostic and Plugins developed with the Liferay IDE can still be modified using other IDEs.

  • Create a directory called liferay-plugins-sdk in /home/{username}/workspace
  • Extract Liferay Plugins SDK to the newly created liferay-plugins-sdk directory.

Configure Eclipse for Liferay Development #

Liferay IDE #

Install Liferay IDE by doing the following:

  • Install Liferay IDE in Eclipse by going to Help > Install New Software
  • Paste the following URL in the Work with box and click Add: http://releases.liferay.com/tools/ide/eclipse/galileo/stable/
  • Name the site: Liferay IDE

Select Liferay Tooling

Restart Eclipse

Define Liferay Server in Eclipse #

Switch to the Liferay Perspective in Eclipse

Create a new Liferay Server in eclipse by doing the following:

  • Click the Server tab
  • Right-click in the Servers Pane and choose New > Server
  • Select Liferay, Inc. > Liferay v6.0 Server (Tomcat 6)
  • Enter the following for the Liferay Tomcat directory: /home/{username}/workspace/bundles/liferay-portal-6.0.2/tomcat-6.0.26

Configure Liferay Plugins SDK #

Configure the Liferay Plugins SDK by doing the following:

  • Choose Window > Preferences > Liferay > Installed SDKs
  • Click Add
  • Enter the following for Location: /home/{username}/workspace/liferay-plugins-sdk

Import Portal Source Code #

Import the Liferay Portal Source code into Eclipse by doing the following:

  • Right-click in Package Explorer and choose Import
  • Go to General and choose Existing Projects into Workspace
  • Enter the following for the root directory: /home/{username}/workspace/liferay-portal-src-6.0.2
  • liferay-portal-src-6.02 should show up in the Project list
  • Click Finish

Creating a Test Plugin #

This section will create a test plugin to make sure that the development environment is properly configured.

  • In the Liferay Perspective click File > New > Liferay Plug-in Project
  • Name the project Test and click Finish
  • Click File > New > Liferay Portlet
  • Make sure the Test-portlet project is selected
  • Choose javax.portlet.GenericPortlet as the Superclass and click Finish
  • Drag and drop the Test-portlet project onto the Liferay Portal server in the servers pane.
  • Start the Liferay Portal Server
  • Once the Server is started, Right-click the Server and choose Liferay > Open Portal Home
  • Log in to Liferay using the username/password test@liferay.com/test
  • Click Add > More > Sample
  • Drag NewPortlet onto the Welcome Page

Debugging in Eclipse #

Set a break point in the Test-Portlet #

  • In the Test-Portlet project go to docroot/WEB-INF/src > com.test and open NewPortlet.java
  • Set breakpoint on the following line: include(viewJSP, renderRequest, renderResponse);

Start the Liferay Server in Debug mode #

  • Double-click the Liferay Server
  • Click Open launch configuration
  • Click the Source Tab and add the Java Project Test-portlet
  • Save the server configuration.
  • Right-click the Liferay Server and choose Restart in Debug.

After Liferay has started, a Debug session should start at the break point that you have set in the Test-Portlet project.

Liferay Plugin Source Code Management #

Checking Liferay projects into and out of a Source Code Management system is a little different because of the Liferay Plugins SDK. Liferay projects are quietly being added to the Liferay Plugins SDK in the background which leads to interesting issues when checking out of Subversion or CVS. A project must be re-associated with the Plugins SDK on checkout. Failure to do so will cause the project to quit working properly in Eclipse. This is being worked on for a later version of the Liferay IDE: http://issues.liferay.com/browse/IDE-102.

Here is a workaround until the fix is implemented:

  • Check the Test-portlet project into Subversion or CVS.
  • Delete the project from Eclipse
  • Go into Subversion or CVS and Right-click the project and choose Check Out As
  • Uncheck the option: Use default workspace location
  • Enter the following as the location: /home/{username}/workspace/liferay-plugins-sdk/portlets/Test-portlet

The project should now be re-associated with the Liferay Plugins SDK and should function normally.

0 添付ファイル
21672 参照数
平均 (4 投票)
平均評価は5.0星中の5です。
コメント
コメント 作成者 日時
Thanks for the guide, it's really well-written.... Samuel Liu 2010/07/16 11:51
Good to hear! I plan on updating it for Helios... Jamie L Sammons 2010/08/03 18:06
Fantastic guide! Thanks! Alfonso Dou Oblanca 2010/08/17 12:09

Thanks for the guide, it's really well-written. I'm currently developing on Lucid too and it was helpful.
投稿日時:10/07/16 11:51
Good to hear! I plan on updating it for Helios and 6.0 GA3 once it ships.
Samuel Liuへのコメント。投稿日時:10/08/03 18:06
投稿日時:10/08/17 12:09