There are two ways to deploy a Maven-built Liferay project:
- Copy your generated Maven JAR/WAR 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 line.
Although manually copying your JAR/WAR 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 project to Liferay DXP with one command execution.
If you’re deploying a module JAR, 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>3.2.1</version> <executions> <execution> <id>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 executions tag, 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.1-ga1</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.