Sunday, February 14, 2010

Liferay Plugin SDK Development Environment Setup

Steps to create Liferay plugin SDK Development Environment Setup.

Step 1
Create a folder in c: or d: anywhere (In my case it is workliferay)
Step 2
Download, extract Liferay plug-in sdk zip and keep only the extracted folder in workliferay. It should only contain folder like client, hooks, themes etc...
Step 3
Download, extract Liferay 5.2.3 and tomcat 5.5.27 bundle and keep it under workliferay. It should only contain folder like common, tomcat5.5.27 etc...
Step 4
Download, extract apache ant 1.8.0 and keep it under workliferay. It should only contain folder like bin, etc ...
Step 5
Set the JAVA_HOME in environment variables.
(ex: C:\java\jdk1.5.0)
Set the ANT_HOME in environment variables.
(ex: D:\workliferay\apache-ant.1.8)
Add ant path to path environment variable.
(ex: D:\workliferay\apache-ant.1.8\bin)
(Note: do note replace path just add at the end of the existing value)
Make sure ant is working or not (Go to cmd and type ant, it say build file or something instead of command not found.)
Step 6
Make sure that all your values are set correctly for liferay plug-in sdk.
Go to D:\workliferay\liferay-plugins-sdk-5.2.3, you will find a build.properties
Open the file in a text editor; you can see lot of configurations commented.
Go to your version of tomcat and make a copy of the same and remove the comments and set the correct values according to your setup. For example.
app.server.dir=D:/workliferay/liferay-portal-5.2.3/tomcat-5.5.27
app.server.classes.portal.dir=D:/workliferay/liferay-portal-5.2.3/tomcat-5.5.27/webapps/ROOT/WEB-INF/classes
app.server.lib.global.dir=${app.server.dir}/common/lib/ext
app.server.lib.portal.dir=D:/workliferay/liferay-portal-5.2.3/tomcat-5.5.27/webapps/ROOT/WEB-INF/lib
app.server.portal.dir=${app.server.dir}/webapps/ROOT
Step 7
Go to D:\workliferay\liferay-portal-5.2.3\tomcat-5.5.27\bin and hit startup.bat
You will see tomcat console and open Liferay as http://localhost:8080/web/guest
Make sure your liferay is starting and working.
Step 8
Creating a new Portlet.
Open a command prompt and navigate to D:\workliferay\liferay-plugins-sdk-5.2.3
See there are many folders, to create a Portlet just navigate to portlets folder.
Now hope you are at D:\workliferay\liferay-plugins-sdk-5.2.3\portlets\>
Hit a command "create portlet name "Display name of the Portlet"
Ex: create MyFirst "My First Portlet"
Now you can see MyFirst-portlet folder created under portlets folder, hit dir and see.
This is just a template; if you want you can customize and add anything that you want.
If you can go to MyFirst-portlet folder you can see docroot and one more build.xml
Run the build.xml (go to MyFirst-portlet folder and hit ant simply)
It creates a .war file for the Portlet created and the same will be copied to your deploy location of Liferay portal.
You can refer in the property in your build.properties file as "auto.deploy.dir=${app.server.dir}/../deploy"
Since Liferay tomcat is already running it will deploy the war automatically, you can watch tomcat console to see what is happening.
Once you see the message saying the Portlet is ready for use then refresh the browser window and go to add application, find the Portlet and add it to your page.

About Me

S/W Engineer, Interested in Learning and Teaching.