With Maven it’s easy to deploy plugins to a Liferay Portal instance. Just follow these steps:
-
Make sure your parent POM’s Liferay-specific properties specify the correct Liferay version and your Liferay Portal’s deploy directory path.
Here’s an example of these properties using Liferay 6.1.30 and a deploy directory path of
E:\liferay-portal-6.1.30-ee-ga3\deploy
:<properties> <liferay.auto.deploy.dir>E:\liferay-portal-6.1.30-ee-ga3\deploy</liferay.auto.deploy.dir> <liferay.version>6.1.30</liferay.version> </properties>
If you haven’t already created a parent plugin project, see Using a Parent Plugin Project for details.
-
In your command prompt, navigate to your Liferay plugin project’s directory.
-
Package your plugin by entering
mvn package
Your command output should be similar to the following output:
[INFO] Building war: E:\ce-plugins-maven\sample-parent-project\sample-portlet\target\sample-portlet-1.0-SNAPSHOT.war ... [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------
-
Deploy the plugin into your Liferay bundle by entering
mvn liferay:deploy
The command output should look similar to the following output:
[INFO] Deploying sample-portlet-1.0-SNAPSHOT.war to [liferay version]\deploy [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------
Your Liferay console output shows your plugin deploying. It looks like this:
INFO: Deploying web application directory [liferay version]\[tomcat version]\webapps\sample-portlet INFO [pool-2-thread-2][HotDeployImpl:178] Deploying sample-portlet from queue INFO [pool-2-thread-2][PluginPackageUtil:1033] Reading plugin package for sample-portlet
-
If you’re deploying the plugin to a release or snapshot repository, specify the repository by adding a distribution management section to your plugin’s
pom.xml
.Here’s an example distribution management section for a snapshot repository:
<distributionManagement> <repository> <id>liferay-releases</id> <url>http://localhost:8081/nexus/content/repositories/liferay-releases</url> </repository> <snapshotRepository> <id>liferay-snapshots</id> <name>Liferay Snapshots Repository</name> <url>http://localhost:8081/nexus/content/repositories/liferay-snapshots</url> </snapshotRepository> </distributionManagement>
The proper contents for your
<distributionManagement>
element can be found in the Summary tab for each of your repositories.Since you created the plugin as a snapshot, you’ll have to deploy it to a snapshot repository. You can deploy a plugin as a release, but the plugin’s POM must specify a valid release version (e.g.,
<version>1.0</version>
), not a snapshot version (e.g.,<version>1.0-SNAPSHOT</version>
). -
Deploy your plugin into your specified Nexus repository:
mvn deploy
Now that you’ve deployed a plugin using Maven, let’s consider the types of Liferay plugins you can develop with Liferay Maven archetypes.