Thursday, July 15, 2010

Liferay 6 Plugins SDK and the Deploy Path

So I'm excited to start creating and deploying portlets in the new Liferay 6 portal, so even though I've built portlets for Liferay 5 already I wanted to go step by step in version 6 as if I'd never done it before, in case there were differences.

I'm doing this in Linux Ubuntu, although that shouldn't matter in this case.

Well as always, getting the SDK set up is pretty easy but when we say "easy" what we really mean is "Done in very few steps." It still assumes an awful lot about your situational awareness, as it were, as well as the adaptability of the tools you're working with.

This is Liferay Plugins SDK 6.0.2 by the way, and the Liferay itself is bundled with Tomcat 6.

When setting up your environment the best practice, according to the manual written by Richard Sezov, Jr (which I'm enjoying very much, by the way), is to have a folder structure that looks a bit like this:

[Code Home]/bundles/[Liferay Bundle]
[Code Home]/plugins

Now, this seems pretty clear, doesn't it? Just drop your unzipped Liferay Portal bundle into /bundles then alongside that your unzipped SDK. Simple, right? Well yeah, and no.

This notation is a bit confusing. When I set up a Liferay portal bundle on my development machine I like to keep the name of the original unzipped folder. The reason for this is at this moment I actually have 3 different Liferay bundles on my development computer, any one of which I may need to use at any time, and by keeping the original folder names I keep them straight and avoid confusion. This is what my structure looks like:

[Code Home]/liferay-portal-6.0.2/tomcat-6.0.26
[Code Home]/liferay-plugins-sdk-6.0.2

There is a side effect to this, you're going to have to fix your build properties. You see, the default configuration in the build.properties file in your SDK is assuming that your Liferay bundle is in a folder called /bundles and the actual tomcat home folder is inside that. In other words, it thinks you're renaming /liferay-portal-6.0.2 to /bundles. You could do that if you want to, but I prefer to keep my development structure consistent so I changed the default. To do that:

Create a file in the SDK directory and name it build.[your username].properties. In this file add the line:

app.server.dir=${project.dir}/../liferay-portal-6.0.2/tomcat-6.0.26

This overrides the line in build.properties that sets the app.server.dir variable to ${project.dir}/../bundles/tomcat-6.0.26.

Nice, huh?

Now when you run the create.sh to start building your new portlet it will follow the structure you've created.




No comments:

Post a Comment