Deploying a Project Built with Maven to Liferay DXP

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

  1. Copy your generated Maven JAR/WAR 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 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.

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

    <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 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:

    <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>
    
  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.

« Creating a Module JAR Using MavenCreating a Maven Repository »
Este artigo foi útil?
Utilizadores que acharam útil: 0 de 0