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:

http://maven.apache.org/guides/mini/guide-creating-archetypes.html

This involved editing these property and xml files:

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:

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:

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.

8 Responses to “Mavenizing the Liferay Plugin SDK”

  1. 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.

  2. jesley says:

    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 http://www.aukcell.com

    Online contact : Skype : aukcell AIM: eonpeter

  3. Nikhil says:

    This is to test

  4. Thanks Henrik!
    I added a comment to http://issues.liferay.com/browse/LEP-4965 asking about the status and suggested to use dedicated repository instead of public one. I got an optimistic response from Thiago Moreira (see the JIRA issue).

  5. Henrik Bernström says:

    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.

  6. My attempt to mavenize the Liferay Plugin SDK is available here http://wiki.github.com/azzazzel/liferay-maven-sdk/. I believe I manged to also integrate ServiceBuilder into the maven build process. See the example portlet and my blog post – http://milen.commsen.com/2009/10/creating-liferay-portlet-with-liferay-maven-sdk.html.

  7. Jason Shao says:

    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?

  8. Henrik Bernström says:

    It’s pretty exciting to read the Liferay Road Map for version 5.3.

    http://tinyurl.com/clpuya (see #6)

Leave a Reply