Mavenizing the Liferay Plugin SDK

Liferay is the leading Open Source enterprise portal platform in the Java market. It’s certainly an impressive piece of software. I’ve been following it for some time now and the product is improving a great deal in many areas, perhaps most in end user usability.

One area that, in my opinion, could still be improved is the development environment. It may be a heck of a good build system Liferay has come up with, but at the bottom line it takes time to learn it and to just start studying it you easily become a bit uncertain. It consists of homegrown ant scripts. To have a flatter learning curve for newcomers Maven 2 might be suitable.

Anyway, I sat down one evening some time ago and looked into how Maven 2 could be used for creating Jsp Portlets for Liferay. Some hours later the work had resulted in a new archetype for creating Liferay Jsp Portlets.

The structure and content of the standard Liferay Jsp Portlet can be viewed here.

So, what did I do?

1. I followed these instructions to manipulate the Jsp Portlet part of Liferay’s plugin SDK into a maven archetype:

This involved editing these property and xml files:
author=Liferay, Inc.


to insert ${artifactId} and ${groupId} for the portlet name and package structure. These files are part of the file list finally being wrapped up within the archetype and used to generate the resulting portlet from Maven 2.

2. I ran ‘mvn install‘ on that particular archetype to have it installed in my local repository.

3. I used the archetype to create a new Liferay Jsp Portlet artifact:

mvn archetype:create -DarchetypeGroupId=com.liferay.maven.archetypes.portlet.jsp

4. I stepped into the artifact and ran ‘mvn install‘ on it which generated my MyFirstLiferayJspPortlet-1.0-SNAPSHOT.war.

5. I then uploaded the war file to my portal instance via the Liferay admin GUI Plugin Installer.

6. Et voila. It worked, showing up in the portal.

And of course, worth mentioning, to have a development environment up and running in eclipse in seconds this is all you have to do:

1. mvn eclipse:add-maven-repo -Declipse.workspace=[full-path-to-workspace]

2. mvn eclipse:eclipse

To have the archetype play with the existing build situation of Liferay it would probably need to be generated from some ant target and be based on the portlet template in subversion located at “plugins/tools/portlet_tmpl/” to have it follow updates of Liferay.

Here you can download the final result, as a zipped archetype.

If a generated archetype like this was to be uploaded to a public maven repository, working from above point #3 and down is what would be necessary for a developer to have a project and all the necessary property and xml files (correctly edited with package structures and all) in place for a Liferay Jsp Portlet development environment. It could at least become a complement to the Plugins SDK. And yes, it could for sure still be enhanced. For example, there is no JSPPortletTest class generated for the JSPPortlet class.

This Post Has 8 Comments

  1. Jason Shao

    So we’ve also been looking at Liferay & Maven – in many cases we’ve ended up wrapping ANT. We have a pretty generic JSR-168 archetype for Spring/JPA/Hibernate that drops out Liferay deployer files – have been trying to stay container agnostic, some convenience goals for hooking up with Hudson for remoteDeploy.

    We’ve also wrapped some existing portlets like WOL & GoogleGadgets in light Maven wrappers around the ANT scripts, the one thing we haven’t really yet tackled yet though is lots of ServiceBuilder integration — that kind of scares us — you looked yet?

  2. Henrik Bernström

    Jason: Sorry for the late reply (missed your comment) but no, I have not looked into the ServiceBuilder and Maven wrapping. It looks like Milen has done some work there, though.

    Milen: Great work. Have you got any respons / reaction from Liferay regarding this? It looks like Liferay will publish artifacts to some public Maven repository, according to their v5.3 roadmap, anyway.

  3. Nikhil

    This is to test

  4. jesley

    Aukcell is a recognized expert in all aspects of Liferay deployment. There are lots of details that you need to setup correctly in order to make Liferay work your way. We know them all. Business case? Architecture? Theme? Custom portlets? Performance tuning? Migration from other portals? We have done that. And much more. please visit

    Online contact : Skype : aukcell AIM: eonpeter

  5. Liferay Partners

    I have refer lots of tutorial regarding Liferay Plugin SDK, but non of them is work for me,
    after doing these step and referring information given by this blog, i solved my problem and working like charm.

Leave a Reply