Maven is a viable option for managing Liferay projects if you don’t want to use Liferay’s default Gradle management system. Liferay provides several Maven plugins for generating and managing your project. Liferay also provides easy to obtain Maven artifacts that are required for Liferay Maven module development. Here, you’ll learn how to

  • Install Liferay Maven artifacts
  • Create/Manage a Maven Repository
  • Apply Maven plugins

Because Liferay DXP is tool-agnostic, Maven is fully supported for Liferay DXP development. Read on for details about these topics.

Installing Liferay Maven Artifacts

To create Liferay projects using Maven, you’ll need its dependencies. This isn’t a problem—Liferay provides them as Maven artifacts. You can retrieve them from a remote repository.

There are two remote repositories that contain Liferay artifacts: Central Repository and Liferay Repository. The Central Repository is the default repository used to download artifacts if you don’t have a remote repository configured. Using the Central Repository to install Liferay Maven artifacts only requires that you specify your module’s dependencies in its pom.xml file.

When packaging your module, the automatic Maven artifact installation process only downloads the artifacts necessary for that module from the Central Repository.

The Central Repository usually offers the latest Liferay Maven artifacts, but the Liferay Repository guarantees access to the latest artifacts released by Liferay. Other than a slight delay in artifact releases, the two repositories are identical. When the Liferay repository is configured in your settings.xml file, archetypes are generated based on that repository’s contents. The Liferay Maven repository offers a good alternative for those who want the most up-to-date Maven artifacts produced by Liferay.

Next, you’ll learn about managing your Maven artifacts.

Managing Maven Artifacts in a Repository

You can share Liferay artifacts and modules with teammates or manage your repositories using a GUI by using Sonatype Nexus. It’s a Maven repository management server for creating and managing release servers, snapshot servers, and proxy servers. There are several other Maven repository management servers you can use (for example, Artifactory), but this section focuses on Nexus.

You’ll learn how to

Before using repository servers, you must specify them in your Maven environment settings. Your repository settings let Maven find the repository and retrieve and install artifacts. You can configure your local Maven settings in the [USER_HOME]/.m2/settings.xml file.

To deploy to a remote repository, your Liferay project should be packaged using Maven. Maven provides a packaging command that creates an artifact (JAR) that can be easily deployed to your remote repository.

Once you’ve created a deployable artifact, you can configure your module project to communicate with your remote repository and use Maven’s deploy command to send it on its way. Once your module project resides on the remote repository, other developers can configure your remote repository in their projects and set dependencies in their project POMs to reference it.

Applying Maven Plugins

There are several important Maven plugins that provide important functionality to Liferay Maven projects. The available Liferay Maven plugins are available in the Maven Plugins section.

The following tasks are covered in this section:

Read on to learn more!

« Updating Default Plugins Provided by Liferay WorkspaceInstalling Liferay Maven Artifacts »
¿Fue útil este artículo?
Usuarios a los que les pareció útil: 0 de 0