Upgrading Your Maven Build Environment

If you’re an avid Maven user and have been using it for Liferay Portal 6.2 project development or older, you must upgrade your Maven build to be compatible with Liferay DXP 7.2 development. There are two main parts of the Maven environment upgrade process that you must address:

For more information on using Maven with Liferay DXP 7.2, see the Maven section.

Liferay also offers a Maven development environment tailored specifically for Liferay DXP 7.2 development. Learn more about this in the Liferay Workspace section.

You’ll start off by upgrading your Maven environment’s Liferay Maven plugins.

Upgrading to New Liferay DXP 7.2 Maven Plugins

The biggest change for your project’s build plugins is the removal of the liferay-maven-plugin. Liferay now provides several individual Maven plugins that accomplish specific tasks. For example, you can configure Maven plugins for Liferay’s CSS Builder, Service Builder, Theme Builder, etc. With smaller plugins available to accomplish specific tasks in your project, you no longer have to rely on one large plugin that provides many things you may not want.

For example, suppose your Liferay Portal 6.2 project was using the liferay-maven-plugin for Liferay CSS Builder only. First, you should remove the legacy liferay-maven-plugin plugin dependency from your project’s pom.xml file:

<plugin>
    <groupId>com.liferay.maven.plugins</groupId>
    <artifactId>liferay-maven-plugin</artifactId>
    <version>${liferay.version}</version>
    <configuration>
        <autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>
        <liferayVersion>${liferay.version}</liferayVersion>
        <pluginType>portlet</pluginType>
    </configuration>
</plugin>

Then, add the CSS Builder plugin dependency to your project’s pom.xml file:

<plugin>
    <groupId>com.liferay</groupId>
    <artifactId>com.liferay.css.builder</artifactId>
    <version>2.1.3</version>
    <executions>
        <execution>
            <id>default-build</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>build</goal>
            </goals>
        </execution>
    </executions>
        <configuration>
            <docrootDirName>src/main/webapp</docrootDirName>
        </configuration>
</plugin>

Some common Liferay Maven plugins are listed below, with their corresponding artifact IDs and articles explaining how to configure them:

Common Liferay Maven Plugins

NameArtifact IDTutorial
Bundle Supportcom.liferay.portal.tools.bundle.supportBundle Support Plugin
CSS Buildercom.liferay.css.builderCSS Builder Plugin
DB Supportcom.liferay.portal.tools.db.supportDB Support Plugin
Deployment Helpercom.liferay.deployment.helperDeployment Helper Plugin
Javadoc Formattercom.liferay.javadoc.formatterJavadoc Formatter Plugin
Lang Buildercom.liferay.lang.builderLang Builder Plugin
REST Buildercom.liferay.portal.tools.rest.builderREST Builder Plugin
Service Buildercom.liferay.portal.tools.service.builderService Builder Plugin
Source Formattercom.liferay.source.formatterSource Formatter Plugin
Theme Buildercom.liferay.portal.tools.theme.builderTheme Builder Plugin
TLD Formattercom.liferay.tld.formatterTLD Formatter Plugin
WSDD Buildercom.liferay.portal.tools.wsdd.builderWSDD Builder Plugin
XML Formattercom.liferay.xml.formatterXML Formatter Plugin

In Liferay Portal 6.2, you were also required to specify all your app server configuration settings. For example, your parent POM probably contained settings similar to these:

<properties>
    <liferay.app.server.deploy.dir>
        E:\liferay-portal-6.2.0-ce-ga1\tomcat-7.0.42\webapps
    </liferay.app.server.deploy.dir>

    <liferay.app.server.lib.global.dir>
        E:\liferay-portal-6.2.0-ce-ga1\tomcat-7.0.42\lib\ext
    </liferay.app.server.lib.global.dir>

    <liferay.app.server.portal.dir>
        E:\liferay-portal-6.2.0-ce-ga1\tomcat-7.0.42\webapps\root
    </liferay.app.server.portal.dir> 

    <liferay.auto.deploy.dir>
        E:\liferay-portal-6.2.0-ce-ga1\deploy
    </liferay.auto.deploy.dir>

    <liferay.version>
        6.2.0
    </liferay.version>

    <liferay.maven.plugin.version>
        6.2.0
    </liferay.maven.plugin.version
 
</properties>

This is no longer required in Liferay DXP 7.2 because Liferay’s Maven tools no longer rely on your Liferay DXP installation’s specific versions. You should remove them from your POM file.

Awesome! You’ve learned about the new Maven plugins available to you for Liferay DXP 7.2 development. Next, you’ll learn about updating your Liferay Maven artifacts.

Updating Liferay Maven Artifact Dependencies

Many Liferay Portal 6.2 artifact dependencies you were using have changed in Liferay DXP 7.2. See the table below for popular Liferay Maven artifacts that have changed:

Liferay Portal 6.2 Artifact IDLiferay DXP 7.2 Artifact ID
portal-servicecom.liferay.portal.kernel
util-bridgescom.liferay.util.bridges
util-javacom.liferay.util.java
util-slf4jcom.liferay.util.slf4j
util-taglibcom.liferay.util.taglib

For more information on resolving dependencies in Liferay DXP 7.2, see the Resolving a Plugin’s Dependencies article.

Of course, you must also update the artifacts you’re referencing for your projects. If you’re using the Central Repository to install Liferay Maven artifacts, you won’t need to do anything more than update the artifacts in your POMs. If, however, you’re working behind a proxy or don’t have Internet access, you must update your company-shared or local repository with the latest Liferay DXP 7.2 Maven artifacts.

With these updates, you can easily upgrade your Liferay Maven build so you can begin developing projects for Liferay DXP 7.2.

« Using Service Builder in a Maven ProjectTheme Generator »
Was this article helpful?
0 out of 0 found this helpful