Getting Started With Liferay Maven SDK

This article is a legacy article. It applies to previous versions of the Liferay product. While the article is no longer maintained, the information may still be applicable.

In this article 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. Please refer to Maven resources such as Maven: The Complete Reference.


  1. Download and install a Liferay 6.1 bundle.

    Please note, these instructions will be in reference to a Tomcat Bundle, but any bundle can be used. The bundle install location will be referred to as 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.
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="" xmlns:xsi="" xsi:schemaLocation="">
      <properties> <>/path/to/liferay/bundle/deploy</> <liferay.version>6.1.0</liferay.version> </properties> </project>
    Now adjust the groupId and artifactId to match your project. Also set the value of to LIFERAY_HOME/deploy. This is where the plugin is copied for Liferay Portal to deploy. The liferay.version property is set to version of Liferay Portal that you are using.
  3. Open command prompt or terminal and go to your project directory. Next, create a portlet project using a Liferay portlet project template, and run the following command:

    mvn archetype:generate

    That command will create a list of available project templates like below:

    21: remote -> com.liferay.maven.archetypes:liferay-ext-archetype (Provides an archetype to create Liferay extensions.)
    22: remote -> com.liferay.maven.archetypes:liferay-hook-archetype (Provides an archetype to create Liferay hooks.)
    23: remote -> com.liferay.maven.archetypes:liferay-layouttpl-archetype (Provides an archetype to create Liferay layout templates.)
    24: remote -> com.liferay.maven.archetypes:liferay-portlet-archetype (Provides an archetype to create Liferay portlets.)
    25: remote -> com.liferay.maven.archetypes:liferay-servicebuilder-archetype (Provides an archetype to create Liferay Service Builder portlets.)
    26: remote -> com.liferay.maven.archetypes:liferay-theme-archetype (Provides an archetype to create Liferay themes.)
    27: remote -> com.liferay.maven.archetypes:liferay-web-archetype (Provides an archetype to create Liferay webs.)
    Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 171:

    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 version:
    1: 6.0.2
    2: 6.0.3
    3: 6.0.4
    4: 6.0.5
    5: 6.0.6
    6: 6.1.0
    7: 6.2.0-SNAPSHOT

    Choose number 6 for 6.1.0 version. Next you will be asked to provide groupId, artifactId and version:

    Define value for property 'groupId': : com.liferay.sample
    Define value for property 'artifactId': : sample-portlet
    Define value for property 'version': 1.0-SNAPSHOT: :
    Define value for property 'package': com.liferay.sample: :
    Confirm properties configuration:
    groupId: com.liferay.sample
    artifactId: sample-portlet
    version: 1.0-SNAPSHOT
    package: com.liferay.sample
     Y: :

    For groupId use the same as in the first pom.xml. In the tets case it would be com.liferay.sample. For artifactId use 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.

Additional Information

Maven: The Complete Reference

For more information on how Maven is supported, see our page on Fix Delivery Methods.

Important: Information about products not created by Liferay is provided for informational purposes only and does not constitute Liferay Subscription Services recommendation nor endorsement. Liferay also does not assume any responsibility for any instructions herein or referenced regarding these products.

0 人中有 0 人觉得有帮助