Create a Maven Project for Liferay

Prerequisite:

- Maven installed
- Liferay installed into the Maven repository. See the page install-liferay-in-maven-environment.

1 - Create a project from a Maven archetype and from the command line.

In a dos command, run:

    mvn archetype:generate -DarchetypeGroupId=com.liferay.maven.archetypes -DarchetypeArtifactId=liferay-theme-archetype -DarchetypeVersion=6.1.1 -DgroupId=groupIdOfMyTheme -DartifactId=NameOfMyTheme -Dversion=1.0.0-SNAPSHOT
 
Adapt to your environment:

-6.1.1 by your version of Liferay.
-groupIdOfMyTheme by groupId of your project
-NameOfMyTheme by the name of your project
-1.0.0-SNAPSHOT by the version of your project

You can change the archetype. In this example, the archetype used is liferay-theme-archetype. This archetype generate a theme project. But you also use:

-liferay-ext-archetype
-liferay-hook-archetype
-liferay-layouttpl-archetype
-liferay-portlet-archetype
-liferay-portlet-icefaces-archetype
-liferay-portlet-jsf-archetype
-liferay-portlet-liferay-faces-alloy-archetype
-liferay-portlet-primefaces-archetype
-liferay-portlet-richfaces-archetype
-liferay-servicebuilder-archetype
-liferay-theme-archetype
-liferay-web-archetype

2 - Create a project from a Maven archetype and from Eclipse.

This is another solution to create a project. But in background, it's the same process.

Create a new project from Eclipse.

File->New->Other
Open Maven and select Maven Project



 Click on Next


Click on Next


Select the Default Local Catalog and add Liferay to the filter field.
Select for example liferay-theme-archetype.
By default only the last version of the archetype is displayed. You can unchecked the filter box "Show the last version of Archetype only"
Select Next


Enter the information on your project and click on Finish


3 - Configure your Maven settings.xml

Create a Liferay Profile

Edit the Maven file settings.xml and adapt the paths and the version to your Liferay target.

 <profile>
  <id>MyTargetLiferay-6.1.1</id>
   <properties>
     <liferay.auto.deploy.dir>C:\liferay-portal\deploy</liferay.auto.deploy.dir>
     <liferay.app.server.deploy.dir>C:\liferay-portal\jboss-7.1.1\standalone\deployments</liferay.app.server.deploy.dir>
     <liferay.app.server.lib.global.dir>C:\liferay-portal\tomcat-bundle\lib</liferay.app.server.lib.global.dir>
     <liferay.app.server.portal.dir>C:\liferay-portal\jboss-7.1.1\standalone\deployments\ROOT.war</liferay.app.server.portal.dir>
     <liferay.version>6.1.1</liferay.version>
  </properties>
 </profile>



To activate the profile, add at the end of the file settings.xml

<activeprofiles>
  <activeprofile>MyTargetLiferay-6.1.1</activeprofile>
</activeprofiles>

3 - Build and deploy

 Now you can build and deploy your project,with
    mvn clean install liferay:deploy

1 comment:

  1. Hi Fabien,

    thank you for this tutorial
    I'm new in Liferay Portal and i made big progress with your tutorial
    but i would like to deploy to remote Jboss based Liferay portal
    and i'm facing difficulties to setup maven setting.xml so that deployment goes to remote server.

    I will appreciate one more time your help

    Thanks

    ReplyDelete