Liferay
plugins development with MAVEN is also great choice for liferay
developers.

What
is MAVEN?

MAVEN
is project build tool like ANT but its has more features than ANT
when we build projects using MAVEN.

Apache
Maven is a software project management and comprehension tool. Based
on the concept of a project object model (POM), Maven can manage a
project's build, reporting and documentation from a central piece of
information.

Each
Maven project consist pom.xml in project root directory where we will
defined project build process.

POM
is project object model is one of the build process system which
describes about software project and POM will be specified as xml tag
notation in pom.xml file.

pom.xml
is blueprint of the project and it describes your project’s
directories, required plugins, build sequence, and dependencies. The
POM is your project’s sole descriptive declaration. Once you create
the pom.xml file and invoke the build process.

Entire
project structure defined in pom.xml so that we can manage entire
project from single point and it is easy when we compare with ANT
because ANT build process will be defined in different build.xml
files. MAVEN projects are very easy to understand by developers

Liferay
plugins SDK provides project templates to build sample Plugin
applications in the same way Liferay provides maven archetypes from
which we can create different sample liferay plugins applications.

Archetypes
are the template of project structure and it consist of all required
configurations,its files and directory structure.

We
can have different archetypes like spring archetypes,struts
archetypes and web application archetypes from this we can create
basic project structure from there we can start development.

Same
way liferay also have created different archetypes for each Plugin
type so that we can create basic Plugin projects very easy.

Liferay
Plugin Development with MAVEN

The
following are are the required steps

Install
JAVA

Install
MAVEN

Install
Liferay Portal Server Bundle

Install
Liferay MAVEN Archetypes

Download
Eclipse+Liferay IDE

Create
Liferay Plugin Maven Project from Liferay IDE

Install
JAVA

Liferay
Java based portal so first we need to install Java in our machine
download JDK 1.6 or later version and install.

we
need to set important environment variables such as JAVA_HOME and
need to edit path system variable and add java bin
path(;%JAVA_HOME%/bin;). We need Java 6.0 JRE or greater.

Extract in your
desired location assume in opt directory then maven home path will be
/opt/apache-maven-3.2.3

Now we need to
configure maven environment variables in bash.bashrc or
“/etc/profile”

bash.bashrc
file will be available in /etc/bash.bashrc folder open
in editor and add following configurations.

M2_HOME=/opt/apache-maven-3.2.3

PATH=$PATH:$M2_HOME/bin

export
M2_HOME

export
PATH

Run command mvn
-version in the terminal to verify your installation

Install
Liferay Portal Server Bundle

First
we need to download portal server bundle based on developer choice.
Once we downloaded bundle archive file then extract it in you desired
location then you can see portal server bundle that consist
application server with deployed liferay portal.

Liferay
Portal Server is actual environment to run liferay Plugin
applications. Liferay Portal Run time come up with different
application servers such as tomcat,jboss,glashfish, jetty, geromino,
JOnAS and resin.

Liferay
provided these run time bundle with different server so that we can
use any one based on developer choice.

Assume
we will use tomcat bundle so download
liferay-portal-tomcat-6.2-ce-ga2.zip from above
location.

Now
extract zip file in of your desired location now we are ready with
liferay portal tomcat server.

Also
in the System variables section, select your path variable and click
Edit….

Insert
;%ANT_HOME%\bin;end
of the existed path valueand click OK.

Click
OK to close all system property windows.

Open
a new command prompt “ant -version” then it show ant version
now you have successfully installed ANT.

Now
we are ready with ANT tool

Now
Install Liferay MAVEN Archetypes into Local MavenRepository(${USER_HOME}/.m2/repository)

Open
command prompt/terminal based on your OS issue the following commandNavigate to liferay-portal-maven-6.2-ce-ga2 then issue following command

ant
install

Console shows
output from the artifacts being installed from the Liferay Maven
package into your local repository, typically located in your
${USER_HOME}/.m2/repository directory. Local repository
now contains the Liferay artifacts required to build Liferay plugins

Download
Eclipse+Liferay IDE

Well as of now we
are ready with MAVEN archetypes installed in maven local repository
and Liferay Portal Server now we need a development IDE to create
Liferay MAVEN Project.

Now extract archive
file in desired location then you can see root directory that is
eclipse if you go to root directory then you can see eclipse icon
when we double click on icon then eclipse will be started.

Now
we have done all the required configuration in project pom.xml now we
can deploy project.

Deploy
Liferay Plugin Maven Project

Open
command prompt or terminal and go to newly created liferay Plugin
project location its generally in eclipse work space(LiferayMaven)
then issue following command.

mvn
package

once
build was successful then issue following command to deploy into
portal server

mvn
liferay:deploy

now
portlet will be deployed into portal and you can see build success
message in the console

If
portal already start then you can see Plugin deployment information
in server log file.

Download
sample liferay maven Plugin from below link when you use this project
please make sure you should installed Liferay Maven Archetypes in
your local and you have to change server configuration and versions
information in the pom.xml file.

The
configuration in pom.xml will be changed based on your environment
like version number, server configuration and dependencies versions.

The
above maven setup we have installed maven archetypes in our local
repository that is /.m2/repository.

http://sourceforge.net/projects/lportal/files/Liferay%20Portal/6.2.1%20GA2/We
have created liferay maven project from Liferay IDE tool without
Liferay IDE also we can create liferay plugins from command
prompt/terminal.

We
have create Pluginv portlet project apart from that we can also
create all liferay plugins like hook,web,ext,theme and layouttpl from
liferay maven archetypes.