Deploying Liferay artifacts to your own maven repository

As part of Liferay 6.1 release we’ve created a new package that has a convenient  script to install Liferay artifacts to your local repository or to a remote repository. This package is provide for both CE and EE releases but it is more useful for EE users because we don’t release EE versions of the artifacts to Maven Central repository.

You can download the 6.1 GA1 package from here and 6.1 EE users can download it from Customer Portal. Once you have downloaded the zip file unzip it.

In the root of the package you’ll find build.properties. This file defines the remote repository location, repository id and optional gpg signing key and password. You can override settings in this file similarly to those in plugins sdk by creating a build.USERNAME.properties file and overriding the properties you want. If you are just deploying to you local repository there’s no need to override any settings.

Before you begin you should make sure you have mvn in your path. For remote deployment you should also increase the available memory for maven otherwise you might get a OutOfMemoryError. For windows you can use following in your cmd prompt or set MAVEN_OPTS environment variable.

set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=128m

For Unix-like systems such as Linux and Mac OS X use

export MAVEN_OPTS=”-Xmx512m -XX:MaxPermSize=128m”

To deploy to your local maven repository you can just run:

ant install

To deploy to a remote repository such as Sonatype Nexus you need to set credential required to deploy to the repository in ${USER_HOME}/.m2/settings.xml like this:

<?xml version=”1.0″?>
<settings>
<servers>
<server>
<id>liferay</id>
<username>admin</username>
<password>password</password>
</server>
</servers>
</settings>

Then you need to add the repository id and repository location to your build.USERNAME.properties like this:

lp.maven.repository.id=liferay
lp.maven.repository.url=http://localhost/nexus/content/repositories/liferay-release

Notice that the repository id must match the one in your settings.xml so that correct credentials are picked up. You can also set gpg.keyname and gpg.passphrase if you want the artifacts signed. Check out this blog post on how to generate gpg key and distribute the public key.

Now you can deploy it just by running:

ant deploy

Now you have following Liferay artifacts at your disposal. Their groupId is com.liferay.portal and artifactId is one listed below and version is the Liferay release number such as 6.1.0 for 6.1 GA1 and 6.1.10 for 6.1 EE1.

  • portal-client
  • portal-impl
  • portal-service
  • portal-web
  • support-tomcat
  • util-bridges
  • util-java
  • util-taglib

This post was originally published on Liferay blog.