| Liferay, Portlets and Maven |
|
|
|
| Written by Josh B |
| Wednesday, 09 February 2011 19:25 |
|
Dashboards seem to be the new Corporate buzzword. There's a dashboard for this and a dashboard for that. The current meme is that whatever the Web App, a dashboard will make it more friendly to end-users. No doubt they are very useful for showing a lot of information at one time. But they can be a pain to develop. That is where a Portal server comes in handy. Liferay is a Portal server that integrates with Tomcat (as well as other Servlet Containers/App Servers). Its very similar to Joomla and Drupal, but has all the advantages that come with Java. Scalability, Reliability and allows developers to use all the API's and development tools that Java enjoys. (Depending on your view of Eclipse, though). My interest in it is that it provides an easy way to get a Java-based Web App to completion, especially Dashboards... There's no more having to develop user management systems, no more having to develop a custom UI, or even spend time configuring your favourite Web Framework. (Struts 2, help...!) Here's a quick tutorial on installing Liferay so that you can use Maven (and Eclipse) to help develop Portlets. First download and install Liferay from the Liferay website. (Make sure you expand the drop-downs to see all the files.) Download and unzip both liferay-portal-src-6.0.5.zip and liferay-portal-tomcat-6.0.5.zip in a directory called liferay. Rename liferay-portal-6.0.5 to bundle. Make a directory called plugin-sdk liferay-plugins-sdk-6.0.5 and unzip liferay-plugins-sdk-6.0.5.zip in it. From the bundle directory make sure you remove the sevencogs-hook and sevencogs-theme directories from the Tomcat Webapp directory. (If you leave them in they will install the demo content into the database : annoying...!) Add a file called portal-ext.properties into webapps/ROOT/WEB-INF/classes: ## MySQL Create this database in Mysql. You can now start Liferay. It will go away and install the needed tables and some demo data. Log in with the default user / pass of " This e-mail address is being protected from spambots. You need JavaScript enabled to view it /test". It's probably best to create your own user. Go to the Liferay source folder, and add the following lines to build.properties maven.version=6.0.5 The version number is the version of Liferay that you are using and this is added to the poms generated for all the Jars. (The Repository Url isn't important as there appeared to be a bug in the deploy section.) Be careful when running the make jars command as with me it seemed to destroy my Liferay install. Backup your current installation before doing so. (I think this happened when "clean" ran...) ant clean start jar Now store the Jars made in your local repository (ie, on your machine). ant -f build-maven.xml install-artifacts Now, go to the Plugins SDK and create a temporary Portlet with the script in liferay-plugins-sdk-6.0.5/portlets/. (You will have to give the scripts appropriate permissions to do this.) ./create.sh test Now create Portlet Project outside of your normal Eclipse workspace. This will be the project we will be working on in Eclipse. mvn archetype:generate The Liferay Portlet Archtype is option 10. Now find the temporary portlet you created with the "create.sh" script. Copy the tld directory in the WEB-INF directory to your new Maven based projects WEB-INF directory. Eg: cd ~/bin/liferay/liferay-plugins-sdk-6.0.5/portlets/test-portlet/docroot/WEB-INF Convert the project into an Eclipse project: mvn eclipse:eclipse Import the Project into Eclipse with the Existing Project Importer. Be sure to copy the Project into your workspace. You will need to update the pom.xml file to point to the correct place to deploy files. Change the liferay.auto.deploy.dir property so it looks like: <properties> You can now code your Portlet in Eclipse. When you are ready to test your efforts, use the following to deploy the portlet in Liferay. mvn -Dmaven.test.skip clean package Of course, we could just copy (cp) the war file from the target directory to Liferay, but this makes a much more stream-lined approach. It also means we can then start to integrate the war into other applications (ie, a Testing Suite such as Continuum or Hudson). Happy Portleting...!
See also : Liferay and Ajax
Top Tip: To use the JSTL you will need to add both standard-1.1.2.jar and jstl-1.2.jar to the Liferay Tomcat Ext Lib directory. |
| Last Updated on Thursday, 17 February 2011 15:16 |





Comments
Huge from Chile.
Andrés Quote
2 corrections:
1. Rename liferay-portal-6.0.5 to bundles
2. Go to the Liferay source folder, and add the following lines to build.your_username.properties Quote
RSS feed for comments to this post.