There are two ways to deploy a Maven-built Liferay module:
- Copy your generated Maven module JAR to your Liferay DXP instance’s
- 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.
Add the following plugin configuration to your Liferay Maven project’s parent
<build> <plugins> <plugin> <groupId>com.liferay</groupId> <artifactId>com.liferay.portal.tools.bundle.support</artifactId> <version>2.0.1</version> <executions> <execution> <id>default-deploy</id> <goals> <goal>deploy</goal> </goals> <phase>pre-integration-test</phase> </execution> </executions> </plugin> </plugins> </build>
This POM configuration applies Liferay’s Bundle Support plugin by defining its
version. You can learn more about this plugin in the Maven Workspace tutorial. The logic also defines the
executionstag, which configures the Bundle Support plugin to run during the
pre-integration-testphase of your Maven project’s build lifecycle. The
deploygoal is defined for that lifecycle phase.
By default, the Bundle Support plugin deploys to the Liferay installation in the
bundlesfolder, 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
plugintags, but outside of the
<configuration> <liferayHome>LIFERAY_HOME_PATH</liferayHome> </configuration>
An example configuration would look like this:
<configuration> <liferayHome>C:/liferay/liferay-ce-portal-7.0-ga7</liferayHome> </configuration>
Run this command to deploy your project:
That’s it! Your Liferay Maven project is built and deployed automatically to your Liferay DXP instance.