Deploying a Module Built with Maven to Liferay DXP

There are two ways to deploy a Maven-built Liferay module:

  1. Copy your generated Maven module JAR to your Liferay DXP instance’s /deploy folder.
  2. Configure your Maven project to deploy to the Liferay DXP instance automatically by running a Maven command via the command prompt.

Although manually copying your module JAR for deployment is a viable option, this is an inefficient way to deploy your projects. With a small configuration in your Maven POMs, you can deploy a module to Liferay DXP with one command execution.

In previous versions of Liferay Portal, you were able to execute the liferay:deploy command to deploy your configured Maven project to a Liferay server. This is no longer possible since the liferay-maven-plugin is not applied to Maven projects built from Liferay archetypes.

A prerequisite for this tutorial is to have your project configured to generate an OSGi module JAR; if you haven’t done this, visit the Creating a Module JAR Using Maven tutorial for more information.

  1. Add the following plugin configuration to your Liferay Maven project’s parent pom.xml file.


    This POM configuration applies Liferay’s Bundle Support plugin by defining its groupId, artifactId, and version. You can learn more about this plugin in the Maven Workspace tutorial. The logic also defines the executions tag, which configures the Bundle Support plugin to run during the pre-integration-test phase of your Maven project’s build lifecycle. The deploy goal is defined for that lifecycle phase.

  2. By default, the Bundle Support plugin deploys to the Liferay installation in the bundles folder, located in your plugin’s parent folder. If you do not have your project set up this way, you must define your Liferay home folder in your POM. You can do this by adding the following logic within the plugin tags, but outside of the execution tags:


    An example configuration would look like this:

  3. Run this command to deploy your project:

    mvn verify

That’s it! Your Liferay Maven project is built and deployed automatically to your Liferay DXP instance.

Was this article helpful?
0 out of 0 found this helpful