JGuru
When you need a guru
  • Home
  • About
  • Services
  • Blog
  • Projects
    • Liferay Backup
    • Photo Carousel Portlet
    • Social Comments Portlet
    • Liferay Yubikey OTP Login
  • Contact
February 2 2012

Getting started with Liferay Maven SDK

Mika Koivisto Liferay liferay, maven

This will be the first in series of posts on how to develop Liferay plugins with Maven. In this post we’ll start by creating a new parent project for your plugins and add a portlet project to it. You need to have your maven environment setup with maven and java installed. If you don’t know how to do it I would recommend reading Maven: The Complete Reference from Sonatype, Inc. The chapter 2 has good instructions on how to install maven.

1) Download and install Liferay 6.1.0 bundle. In these posts we assume it’s tomcat bundle but you can use any bundle. I’ll refer to the bundle install location is LIFERAY_HOME from now on. If you need instructions on how to install bundle please refer to Liferay 6.1 User Guide.
2) Create a new directory which will be your project root. This is the location where you would extract Liferay plugins SDK if you were using Ant. Then in that directory create a pom.xml file.
Now you should adjust groupId and artifactId to match you project. Also set the value of liferay.auto.deploy.dir to LIFERAY_HOME/deploy. This is where the plugin is copied for Liferay to deploy. The liferay.version property is set to version of Liferay you are using.
3) Open command prompt or terminal and go to your project directory. Next we’ll going to create a portlet project using a liferay portlet project template. Run
mvn archetype:generate
That command will create a list of available project templates like below:
Choose number 24 or what ever the number you have for com.liferay.maven.archetypes:liferay-portlet-archetype
Next you will be asked to choose the template version:
Choose number 6 or what ever you have for 6.1.0 version.
Next you will be asked to provide groupId, artifactId and version:
For groupId use the same as in the first pom.xml. In my case it would be com.liferay.sample. For artifactId I chose sample-portlet as this is the directory it will create. Version should be the same as the project parent. Once you have confirmed the values maven will create the portlet project and add it to you parent project as module automatically.
Now you project structure should be something like this:
4) Go to sample-portlet directory and run
mvn package
This will compile any classes and packages the portlet war file in target directory.
5) To deploy the portlet into your Liferay bundle you can run
mvn liferay:deploy
Now you have created your first Liferay plugin project with maven and deployed it to your Liferay bundle.

This post was originally published on Liferay blog.

Share this:

  • Tweet
  • Share on Tumblr
Liferay 6.1 GA1 Maven artifacts released Deploying Liferay artifacts to your own maven repository

Related Posts

fail

Liferay

Top 3 reasons why Liferay projects fail

FIDO-Yubico-YubiKeys-2-444x296

Liferay

Liferay Yubikey OTP Login

Liferay

Liferay Maven Support in Liferay 6.1 GA3

Tags

activemq apache backup c3p0 certificate connection pool debian debugging deployment git heap hook httpd https installer java jms jmx jmx4perl jndi jolokia jvm liferay mariadb maven memory monitoring mrtg mysql nagios newrelic nginx ngx_cache_purge pagespeed performance repository salesforce saml security spring ssl struts tls tomcat ubuntu

Categories

  • General
  • Howto
  • Liferay

Recent Posts

  • cyber_securityHow to get Tomcat to see HTTPS when it’s terminated elsewhere
  • failTop 3 reasons why Liferay projects fail
  • FIDO-Yubico-YubiKeys-2-444x296Liferay Yubikey OTP Login
  • nginxCreating a custom Nginx build for Ubuntu/Debian
  • getting-git-rightMoving a project from one git repository to another while retaining it’s history

Archives

  • October 2017
  • February 2017
  • January 2017
  • July 2016
  • June 2016
  • May 2016
  • August 2015
  • April 2015
  • January 2015
  • October 2013
  • June 2013
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • March 2012
  • February 2012
  • January 2012
  • January 2011
  • September 2010
  • August 2010
  • December 2009
  • October 2008
  • December 2007

Recent Posts

  • cyber_securityHow to get Tomcat to see HTTPS when it’s terminated elsewhere
  • failTop 3 reasons why Liferay projects fail
  • FIDO-Yubico-YubiKeys-2-444x296Liferay Yubikey OTP Login
  • nginxCreating a custom Nginx build for Ubuntu/Debian
  • getting-git-rightMoving a project from one git repository to another while retaining it’s history

Follow me on Twitter

My Tweets
© JGuru 2006 - 2017