Installing Liferay Maven Artifacts

To create Liferay modules using Maven, you’ll need the archives required by Liferay (e.g., JAR and WAR files). This isn’t a problem–Liferay provides them as Maven artifacts. You can retrieve them from a remote repository.

There are two 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. The Central Repository usually offers the latest Liferay Maven artifacts, but using the the Liferay Repository guarantees the latest artifacts released by Liferay. Other than a slight delay between artifact releases between the two repositories, they’re identical. You’ll learn how to reference both of them next.

Using the Central Repository to install Liferay Maven artifacts only requires that you specify your module’s dependencies in its pom.xml file. For example, the snippet below sets a dependency on Liferay’s com.liferay.portal.kernel artifact:


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

You can view the published Liferay Maven artifacts on the Central Repository by searching for liferay maven in the repo’s Search bar. For convenience, you can reference the available artifacts at|ga|1|liferay maven. Use the Latest Version column as a guide to see what’s available for the intended version of Liferay DXP for which you’re developing.

If you’d like to access Liferay’s latest Maven artifacts, you can configure Maven to use Liferay’s Nexus repository instead by inserting the following snippet in your project’s parent pom.xml:

        <name>Liferay Public Releases</name>

The above configuration retrieves artifacts from Liferay’s release repository.

If you’ve configured the Liferay Nexus repository to access Liferay Maven artifacts and you’ve already been syncing from the Central Repository, you may need to clear out parts of your local repository to force Maven to re-download the newer artifacts. Also, do not leave the Liferay repository configured when publishing artifacts to Maven Central. You must comment out the Liferay Repository credentials when publishing your artifacts.

The Liferay Maven repository offers a good alternative for those who want the most up-to-date Maven artifacts produced by Liferay.

Congratulations! You’ve downloaded the Liferay artifacts and installed them to your chosen repository.

« MavenGenerating New Projects Using Archetypes »