To learn how to use Liferay IDE to create Liferay Maven plugins, please refer to the Creating Liferay Maven Plugins from Liferay IDE tutorial. This tutorial explains how to use Maven archetypes to generate Liferay plugin projects using the command line.
Using the Maven Archetype Tool to Create a Liferay Plugin
Follow these steps to create a Liferay plugin from the command line:
-
Open the command prompt or terminal and navigate to the parent directory in which you want to create the plugin project. Create a sub-directory for each plugin project you create.
-
Execute the following command:
mvn archetype:generate
Archetype starts and lists the archetypes available to you. You’re prompted to choose an archetype or filter archetypes by group / artifact ID. The output looks like this:
... 39: remote -> com.liferay.maven.archetypes:liferay-hook-archetype (Provides an archetype to create Liferay hooks.) 40: remote -> com.liferay.maven.archetypes:liferay-layouttpl-archetype (Provides an archetype to create Liferay layout templates.) 41: remote -> com.liferay.maven.archetypes:liferay-portlet-archetype (Provides an archetype to create Liferay portlets.) 42: remote -> com.liferay.maven.archetypes:liferay-portlet-icefaces-archetype (Provides an archetype to create Liferay ICEfaces portlets.) 43: remote -> com.liferay.maven.archetypes:liferay-portlet-jsf-archetype (Provides an archetype to create Liferay JSF portlets.) ... Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains):
-
To find the right Liferay archetype for your project, you can either scroll up to find it or apply filters to narrow the set of results. Filtering on liferay as your group ID, and a plugin type (portlet, hook, theme, etc.) can help you focus on more applicable Liferay archetypes.
Entering
liferay:portlet
as a filter gives a listing of Liferay portlet archetypes:Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : liferay:portlet Choose archetype: 1: remote -> com.liferay.maven.archetypes:liferay-portlet-archetype (Provides an archetype to create Liferay portlets.) 2: remote -> com.liferay.maven.archetypes:liferay-portlet-icefaces-archetype (Pr ovides an archetype to create Liferay ICEfaces portlets.) 3: remote -> com.liferay.maven.archetypes:liferay-portlet-jsf-archetype (Provide s an archetype to create Liferay JSF portlets.) 4: remote -> com.liferay.maven.archetypes:liferay-portlet-liferay-faces-alloy-ar chetype (Provides an archetype to create Liferay Faces Alloy portlets.) 5: remote -> com.liferay.maven.archetypes:liferay-portlet-primefaces-archetype ( Provides an archetype to create Liferay PrimeFaces portlets.) 6: remote -> com.liferay.maven.archetypes:liferay-portlet-richfaces-archetype (P rovides an archetype to create Liferay RichFaces portlets.) Choose a number or apply filter (format: [groupId:]artifactId, case sensitive co ntains): :
-
Choose an archetype by entering its number.
-
You’re prompted to choose the archetype version. Enter the number corresponding to the Liferay version for the archetype. You’re not required, however, to select the archetype version that corresponds with your Liferay instance; older archetype versions are compatible with updated Liferay bundles.
Choose com.liferay.maven.archetypes:liferay-portlet-archetype 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.1.1 8: 6.1.2 9: 6.1.10 10: 6.1.20 11: 6.1.30 12: 6.1.30.1 ... 23: 6.2.1 24: 6.2.10.4 25: 6.2.10.5 26: 6.2.10.6 27: 6.2.10.7 28: 6.2.10.8 29: 6.2.10.9 30: 7.0.0-m1 31: 7.0.0-m2 Choose a number: 31:
-
Enter values for the groupId, artifactId, version, and package coordinates (properties) of your project. Here are some examples:
groupId: com.liferay.sample artifactId: sample-portlet version: 1.0-SNAPSHOT package: com.liferay.sample
This process is illustrated in the snapshot below:
For more information on defining Maven coordinates, see http://maven.apache.org/pom.html#Maven_Coordinates.
-
Enter the letter Y to confirm your coordinates.
Maven’s Archetype tool creates a Liferay plugin project directory with a new
pom.xml
file and source code.
Following these steps, you can use Archetype to generate all your Liferay plugin projects!
Plugin projects generated from a Liferay archetype are equipped with a POM
that’s ready to work with a parent project. It inherits the values for
liferay.version
and liferay.auto.deploy.dir
properties from the parent.
When your plugin is created, you can package and deploy your project to a specified Liferay instance. You can even install and deploy the individual plugin to a remote repository.
Related Topics
Deploying Liferay Plugins with Maven
Developing Liferay Theme Plugins with Maven