maven – JGuru https://jguru.fi When you need a guru Thu, 28 May 2020 01:23:28 +0000 en-US hourly 1 https://jguru.fi/wp-content/uploads/2015/01/javaguru_icon-54c89537v1_site_icon-32x32.png maven – JGuru https://jguru.fi 32 32 83852845 Liferay Maven Support in Liferay 6.1 GA3 https://jguru.fi/liferay-maven-support-liferay-6-1-ga3.html?utm_source=rss&utm_medium=rss&utm_campaign=liferay-maven-support-liferay-6-1-ga3 Tue, 18 Jun 2013 22:25:20 +0000 https://web.liferay.com/web/mika.koivisto/blog/-/blogs/liferay-maven-support-in-liferay-6-1-ga3 We've finally released both CE and EE versions of Liferay 6.1 GA3 and along with those releases we've also released the corresponding versions of Liferay Maven Support and Portal artifacts. The version numbers are 6.1.2 for CE GA3 and 6.1.30 for EE GA3. With this release there is one significant improvement in the Liferay Maven Plugin and that is they are no longer directly dependent on a Liferay Portal version. We could have just released one version and it would have worked with either portal version, in fact they both work with any portal version starting from 6.1.0. In the future we will probably move to a single release of Liferay Maven Support which will eventually have it's own release cycle completely independent of the portals release cycle.  

All the archetypes will now have a separate property for Liferay Maven Plugin version called liferay.maven.plugin.version. The plugin will also now require you to tell which portal version you are developing against and you'll do that by providing it liferayVersion in the configuration section. Here's a example from liferay-theme-archetype:


<plugin>
  <groupId>com.liferay.maven.plugins</groupId>
  <artifactId>liferay-maven-plugin</artifactId>
  <version>${liferay.maven.plugin.version}</version>
  <executions>
    <execution>
      <phase>generate-sources</phase>
      <goals>
        <goal>theme-merge</goal>
        <goal>build-css</goal>
        <goal>build-thumbnail</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>
    <appServerDeployDir>${liferay.app.server.deploy.dir}</appServerDeployDir>
    <appServerLibGlobalDir>${liferay.app.server.lib.global.dir}</appServerLibGlobalDir>
    <appServerPortalDir>${liferay.app.server.portal.dir}</appServerPortalDir>
    <liferayVersion>${liferay.version}</liferayVersion>
    <parentTheme>${liferay.theme.parent}</parentTheme>
    <pluginType>theme</pluginType>
    <themeType>${liferay.theme.type}</themeType>
  </configuration></plugin>

Please remember that the plugin will still be affected any bugs in the Liferay Portal Version so if you have patches installed you should point the plugin to a patched portal bundle by setting the liferay.app.server.xxx properties. If you discover any bugs in any of the plugin mojos please report them to our MAVEN Jira project.

]]>
We’ve finally released both CE and EE versions of Liferay 6.1 GA3 and along with those releases we’ve also released the corresponding versions of Liferay Maven Support and Portal artifacts. The version numbers are 6.1.2 for CE GA3 and 6.1.30 for EE GA3. With this release there is one significant improvement in the Liferay Maven Plugin and that is they are no longer directly dependent on a Liferay Portal version. We could have just released one version and it would have worked with either portal version, in fact they both work with any portal version starting from 6.1.0. In the future we will probably move to a single release of Liferay Maven Support which will eventually have it’s own release cycle completely independent of the portals release cycle.  

All the archetypes will now have a separate property for Liferay Maven Plugin version called liferay.maven.plugin.version. The plugin will also now require you to tell which portal version you are developing against and you’ll do that by providing it liferayVersion in the configuration section. Here’s a example from liferay-theme-archetype:



<plugin>
<groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<version>${liferay.maven.plugin.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>theme-merge</goal>
<goal>build-css</goal>
<goal>build-thumbnail</goal>
</goals>
</execution>
</executions>
<configuration>
<autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>
<appServerDeployDir>${liferay.app.server.deploy.dir}</appServerDeployDir>
<appServerLibGlobalDir>${liferay.app.server.lib.global.dir}</appServerLibGlobalDir>
<appServerPortalDir>${liferay.app.server.portal.dir}</appServerPortalDir>
<liferayVersion>${liferay.version}</liferayVersion>
<parentTheme>${liferay.theme.parent}</parentTheme>
<pluginType>theme</pluginType>
<themeType>${liferay.theme.type}</themeType>
</configuration></plugin>

Please remember that the plugin will still be affected any bugs in the Liferay Portal Version so if you have patches installed you should point the plugin to a patched portal bundle by setting the liferay.app.server.xxx properties. If you discover any bugs in any of the plugin mojos please report them to our MAVEN Jira project.

This post was originally published on Liferay blog.

]]>
266
Debugging Maven Plugins https://jguru.fi/debugging-maven-plugins.html?utm_source=rss&utm_medium=rss&utm_campaign=debugging-maven-plugins https://jguru.fi/debugging-maven-plugins.html#respond Sun, 27 May 2012 08:49:52 +0000 http://javaguru.fi/?p=24 When developing maven plugins things don’t always work the way you expect so you need to debug the Mojo to see what’s really going on. I had a weird case where my plugin worked when I ran it independently but when I ran it with mvn clean package it always failed. First thing you can do is run in debug mode which produces a lot more output and shows all the plugin execution configuration. You can enable it with -X argument like this:

mvn -X clean package

Now that didn’t quite help with my case so next thing I did was to run it with remote debugger. That way I could step through the code line by line and inspect all the variables. To do that you just modify the MAVEN_OPTS environment variable in the shell where you are executing you maven plugin and add java debugger agentlib config like this:

MAVEN_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=y"

I used suspend=y so that it would wait for my debugger to attach before continuing the execution. Then you just add some breakpoints in you IDE and remote debug it like any java application. That by the way solved my issue as I realized each of my Liferay maven plugins were initialing Liferay configuration but since they were all run after each other in the same context only the first one mattered.

]]>
https://jguru.fi/debugging-maven-plugins.html/feed 0 24
Creating Liferay Themes with Maven https://jguru.fi/creating-liferay-themes-maven.html?utm_source=rss&utm_medium=rss&utm_campaign=creating-liferay-themes-maven Fri, 16 Mar 2012 00:37:18 +0000 https://web.liferay.com/web/mika.koivisto/blog/-/blogs/creating-liferay-themes-with-maven Some time ago I posted on how you can get started creating portlets with Liferay Maven SDK now I’m going to show how you can add themes to your project. If you need a refresher on how to get started check out this post.

1) Open command prompt or terminal and go to your project directory. Next we are going to create a theme using the Liferay theme template. Run:

mvn archetype:generate
    -DarchetypeArtifactId=liferay-theme-archetype
    -DarchetypeGroupId=com.liferay.maven.archetypes
    -DarchetypeVersion=6.1.0
    -DartifactId=sample-theme
    -DgroupId=com.liferay.sample
    -Dversion=1.0-SNAPSHOT
For 6.1 EE ga1 use -DarchetypeVersion=6.1.10. 

Now you have your theme project in sample-theme directory with following structure.

sample-theme
sample-theme/pom.xml
sample-theme/src
sample-theme/src/main
sample-theme/src/main/resources
sample-theme/src/main/webapp
sample-theme/src/main/webapp/WEB-INF
sample-theme/src/main/webapp/WEB-INF/liferay-plugin-package.properties
sample-theme/src/main/webapp/WEB-INF/web.xml

2) Open the theme pom.xml file. From the properties section remove liferay.version and liferay.auto.deploy.dir properties. These properties should be defined in the pom.xml in your project root just as we did with the portlet project.

You should also note that there’s two additional properties liferay.theme.parent and liferay.theme.type. These set the parent theme and the theme template language just like in ant based plugins sdk. The property liferay.theme.parent however allows you to define basically any war artifact as the parent. The syntax is groupId:artifactId:version or you can use the core themes: _unstyled, _styled, classic and control_panel.

3) Now you can add your customizations in src/main/webapp. Just follow the same structure as you would do in _diffs. So your custom.css would go to src/main/webapp/css/custom.css.

4) Once you’ve done your customizations and want to create the war file just run

mvn package

It will create the war file just like with any maven war type project. Another thing it will do is download and copy your parent theme and then overlay your changes on top of it. It will also create a thumbnail from src/main/webapp/images/screenshot.png just like ant based plugins sdk does. These are accomplished by adding the theme-merge and build-thumbnail goals into the generate-sources phase.

5) Now deploy the theme into your Liferay bundle by running:

mvn liferay:deploy
]]>
.blog-snippet {
border: 1px solid #DEDEDE;
font-family: Monaco, "Courier New", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace;
margin-bottom: 1em;
overflow: auto;
word-wrap: normal;
background-color: ghostWhite;
white-space:pre-line;
}

Some time ago I posted on how you can get started creating portlets with Liferay Maven SDK now I’m going to show how you can add themes to your project. If you need a refresher on how to get started check out this post.

1) Open command prompt or terminal and go to your project directory. Next we are going to create a theme using the Liferay theme template. Run:

mvn archetype:generate
-DarchetypeArtifactId=liferay-theme-archetype
-DarchetypeGroupId=com.liferay.maven.archetypes
-DarchetypeVersion=6.1.0
-DartifactId=sample-theme
-DgroupId=com.liferay.sample
-Dversion=1.0-SNAPSHOT
For 6.1 EE ga1 use -DarchetypeVersion=6.1.10.

Now you have your theme project in sample-theme directory with following structure.

sample-theme
sample-theme/pom.xml
sample-theme/src
sample-theme/src/main
sample-theme/src/main/resources
sample-theme/src/main/webapp
sample-theme/src/main/webapp/WEB-INF
sample-theme/src/main/webapp/WEB-INF/liferay-plugin-package.properties
sample-theme/src/main/webapp/WEB-INF/web.xml

2) Open the theme pom.xml file. From the properties section remove liferay.version and liferay.auto.deploy.dir properties. These properties should be defined in the pom.xml in your project root just as we did with the portlet project.

You should also note that there’s two additional properties liferay.theme.parent and liferay.theme.type. These set the parent theme and the theme template language just like in ant based plugins sdk. The property liferay.theme.parent however allows you to define basically any war artifact as the parent. The syntax is groupId:artifactId:version or you can use the core themes: _unstyled, _styled, classic and control_panel.

3) Now you can add your customizations in src/main/webapp. Just follow the same structure as you would do in _diffs. So your custom.css would go to src/main/webapp/css/custom.css.

4) Once you’ve done your customizations and want to create the war file just run

mvn package

It will create the war file just like with any maven war type project. Another thing it will do is download and copy your parent theme and then overlay your changes on top of it. It will also create a thumbnail from src/main/webapp/images/screenshot.png just like ant based plugins sdk does. These are accomplished by adding the theme-merge and build-thumbnail goals into the generate-sources phase.

5) Now deploy the theme into your Liferay bundle by running:

mvn liferay:deploy

This post was originally published on Liferay blog.

]]>
270
Deploying Liferay artifacts to your own maven repository https://jguru.fi/deploying-liferay-artifacts-maven-repository.html?utm_source=rss&utm_medium=rss&utm_campaign=deploying-liferay-artifacts-maven-repository Tue, 21 Feb 2012 22:12:38 +0000 https://web.liferay.com/web/mika.koivisto/blog/-/blogs/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
]]>
.blog-snippet {
border: 1px solid #DEDEDE;
font-family: Monaco, "Courier New", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace;
margin-bottom: 1em;
overflow: auto;
word-wrap: normal;
background-color: ghostWhite;
white-space:pre-line;
}

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.

]]>
274
Getting started with Liferay Maven SDK https://jguru.fi/getting-started-liferay-maven-sdk.html?utm_source=rss&utm_medium=rss&utm_campaign=getting-started-liferay-maven-sdk Thu, 02 Feb 2012 01:53:39 +0000 https://web.liferay.com/web/mika.koivisto/blog/-/blogs/getting-started-with-liferay-maven-sdk This will be the first in series of posts on how to develop Liferay plugins with Maven. In this post we’ll start by creating a new parent project for your plugins and add a portlet project to it. You need to have your maven environment setup with maven and java installed. If you don’t know how to do it I would recommend reading Maven: The Complete Reference from Sonatype, Inc. The chapter 2 has good instructions on how to install maven.

1) Download and install Liferay 6.1.0 bundle. In these posts we assume it’s tomcat bundle but you can use any bundle. I’ll refer to the bundle install location is LIFERAY_HOME from now on. If you need instructions on how to install bundle please refer to Liferay 6.1 User Guide.
2) Create a new directory which will be your project root. This is the location where you would extract Liferay plugins SDK if you were using Ant. Then in that directory create a pom.xml file.
Now you should adjust groupId and artifactId to match you project. Also set the value of liferay.auto.deploy.dir to LIFERAY_HOME/deploy. This is where the plugin is copied for Liferay to deploy. The liferay.version property is set to version of Liferay you are using.
3) Open command prompt or terminal and go to your project directory. Next we’ll going to create a portlet project using a liferay portlet project template. Run
mvn archetype:generate
That command will create a list of available project templates like below:
Choose number 24 or what ever the number you have for com.liferay.maven.archetypes:liferay-portlet-archetype
Next you will be asked to choose the template version:
Choose number 6 or what ever you have for 6.1.0 version.
Next you will be asked to provide groupId, artifactId and version:
For groupId use the same as in the first pom.xml. In my case it would be com.liferay.sample. For artifactId I chose sample-portlet as this is the directory it will create. Version should be the same as the project parent. Once you have confirmed the values maven will create the portlet project and add it to you parent project as module automatically.
Now you project structure should be something like this:
4) Go to sample-portlet directory and run
mvn package
This will compile any classes and packages the portlet war file in target directory.
5) To deploy the portlet into your Liferay bundle you can run
mvn liferay:deploy
Now you have created your first Liferay plugin project with maven and deployed it to your Liferay bundle.

This post was originally published on Liferay blog.

]]>
276
Liferay 6.1 GA1 Maven artifacts released https://jguru.fi/liferay-6-1-ga1-maven-artifacts-released.html?utm_source=rss&utm_medium=rss&utm_campaign=liferay-6-1-ga1-maven-artifacts-released Tue, 10 Jan 2012 00:54:55 +0000 https://web.liferay.com/web/mika.koivisto/blog/-/blogs/liferay-6-1-ga1-maven-artifacts-released  

I’m glad to announce that we have released Liferay maven artifacts to 6.1 GA1. 

All the artifacts will be pushed into the central repository through http://oss.sonatype.org where they are already available. 

This release includes following artifacts:

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

In addition to this we’ve packaged the Liferay artifacts into a convenient zip file called /liferay-portal-maven-6.1.0-ce-ga1-20120106155615760.zip with ant script to allow you to deploy them into your local repository easily. We will be providing this for EE releases as well since EE artifacts will not be available from Central.  

We have also released the Liferay maven plugin and archetypes for all types of Liferay plugins:

- liferay-ext-archetype
- liferay-hook-archetype
- liferay-layouttpl-archetype
- liferay-portlet-archetype
- liferay-servicebuilder-archetype
- liferay-theme-archetype
- liferay-web-archetype

I will post later some instructions on how to use those archetypes. If you’ve used the snapshot version there was one last minute change that requires you to now manually set properties liferay.version and liferay.auto.deploy.dir in your pom.xml. 

]]>
I’m glad to announce that we have released Liferay maven artifacts to 6.1 GA1.

All the artifacts will be pushed into the central repository through http://oss.sonatype.org where they are already available. 

This release includes following artifacts:

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

In addition to this we’ve packaged the Liferay artifacts into a convenient zip file called /liferay-portal-maven-6.1.0-ce-ga1-20120106155615760.zip with ant script to allow you to deploy them into your local repository easily. We will be providing this for EE releases as well since EE artifacts will not be available from Central.

We have also released the Liferay maven plugin and archetypes for all types of Liferay plugins:

– liferay-ext-archetype
– liferay-hook-archetype
– liferay-layouttpl-archetype
– liferay-portlet-archetype
– liferay-servicebuilder-archetype
– liferay-theme-archetype
– liferay-web-archetype

I will post later some instructions on how to use those archetypes. If you’ve used the snapshot version there was one last minute change that requires you to now manually set properties liferay.version and liferay.auto.deploy.dir in your pom.xml.

This post was originally published on Liferay blog.

]]>
278
Liferay Maven SDK https://jguru.fi/liferay-maven-sdk.html?utm_source=rss&utm_medium=rss&utm_campaign=liferay-maven-sdk Tue, 15 Dec 2009 11:16:53 +0000 https://web.liferay.com/web/mika.koivisto/blog/-/blogs/liferay-maven-sdk_1 Starting to recover from jetlag after a two week trip Los Angeles and Liferay retreat. One of the things we finally made some progress during the developer retreat  is providing official maven artifacts for Liferay as well as porting our plugins sdk to Maven. Things are not quite completed but I will provide some instructions here for all early adopters.

So our goal is to provide our CE releases through our own public repository as well as provide means for our EE customers to install the EE versions artifacts to their local maven repository.

If you have ever worked with enterprise projects using maven you already know how important a local maven repository and proxy is. For those not so familiar with Maven a proxy is a server that proxies your requests to public Maven repositories and caches the artifacts locally for faster and more reliable access. Most maven proxies can also host private repositories used for hosting your company's private artifacts. Having a local proxy / repository makes your maven builds much faster and more reliable than accessing remote repositories that might even sometimes be unavailable.

1. Installing a maven proxy / repository

First step is to install and setup Nexus. Nexus is a open source maven repository manager that can proxy to other repositories as well as host repositories. If you just want to try things locally you can skip this step.

  1. Download latest Nexus such as nexus-webapp-1.4.0-bundle.zip
  2. Follow the installation directions of the Nexus book http://nexus.sonatype.org/documentation.html
  3. Startup nexus
  4. Open your browser to your newly created nexus (if you installed it locally it could be accessed by opening http://localhost:8080/nexus)
  5. Login as administrator (default login is admin / admin123)
  6. Go to Repositories and click Add -> Hosted Repository
  7. Give the repository following information and click save
    • Repository ID: liferay-ce-releases
    • Repostory Name: Liferay CE Release Repository
    • Provider: Maven2 Repository
    • Repository Policy: Release
  8. Create another hosted repository with following information
    • Repository ID: liferay-ce-snapshots
    • Repository Name: Liferay CE Snapshot Repository
    • Provider: Maven2 Repository
    • Repository Policy: Snapshot

Now you have a repository ready for Liferay's Maven artifacts. Next step is to configure your maven to be able to upload artifacts to that repository.

 2. Configuring Maven Settings

Open your $HOME/.m2/settings.xml (if the file does not exist create it). Add the servers segment to your settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings>
     <servers>
          <server>
               <id>liferay</id>
               <username>admin</username>
               <password>admin123</password>
          </server>
     </servers>
</settings>

You might also want to make your Nexus as your maven proxy. To do that just add following xml segment to your settings.xml right before servers element.

<mirrors>
     <mirror>
          <id>local</id>
          <name>Local mirror repository</name>
          <url>http://localhost:8080/nexus/content/groups/public</url>
          <mirrorOf>*</mirrorOf>
     </mirror>
</mirrors>

3. Installing Liferay Artifacts to Repository

Next we will install the Liferay Maven artifacts to your repository. First you need to checkout Liferay code from the SVN. 

svn --username guest co svn://svn.liferay.com/repos/public/portal/trunk portal-trunk

Guest user does not require password.

Then create a release.${username}.properties file and add

maven.url=http://localhost:8080/nexus/content/repositories/liferay-ce-snapshots

Build Liferay artifacts by running

ant clean start jar

Now you can deploy the Liferay artifacts to your maven repository by running

ant -f build-maven.xml deploy-artifacts

If you only want to have them locally without a maven repository you can run the install task instead of deploy

ant -f build-maven.xml install-artifacts

Now you can add Liferay dependencies to your maven project. Following artifacts are available:

<dependency>
	<groupId>com.liferay.portal</groupId>
	<artifactId>portal-client</artifactId>
	<version>5.3.0-SNAPSHOT</version>
</dependency>
<dependency>
	<groupId>com.liferay.portal</groupId>
	<artifactId>portal-impl</artifactId>
	<version>5.3.0-SNAPSHOT</version>
	<scope>provided</scope>
</dependency>
<dependency>
	<groupId>com.liferay.portal</groupId>
	<artifactId>portal-kernel</artifactId>
	<version>5.3.0-SNAPSHOT</version>
	<scope>provided</scope>
</dependency>
<dependency>
	<groupId>com.liferay.portal</groupId>
	<artifactId>portal-service</artifactId>
	<version>5.3.0-SNAPSHOT</version>
	<scope>provided</scope>
</dependency>
<dependency>
	<groupId>com.liferay.portal</groupId>
	<artifactId>portal-web</artifactId>
	<version>5.3.0-SNAPSHOT</version>
	<scope>provided</scope>
</dependency>
<dependency>
	<groupId>com.liferay.portal</groupId>
	<artifactId>util-bridges</artifactId>
	<version>5.3.0-SNAPSHOT</version>
</dependency>
<dependency>
	<groupId>com.liferay.portal</groupId>
	<artifactId>util-java</artifactId>
	<version>5.3.0-SNAPSHOT</version>
</dependency>
<dependency>
	<groupId>com.liferay.portal</groupId>
	<artifactId>util-taglib</artifactId>
	<version>5.3.0-SNAPSHOT</version>
</dependency>
NOTE portal-impl and portal-web are provided for maven plugins and should never be added as dependency to your Liferay plugins.

 4. Installing the Liferay Maven SDK

To take full advantage of Maven we are porting the functionality of out ant based Plugins SDK to Maven. To use it you need to install it locally. To install the Liferay maven plugins and archetypes go into support-maven folder and run

mvn install

Now the Liferay Maven SDK is installed and ready to use. We've implemented a portlet archetype and deployer plugin.

5. Creating a Portlet Plugin

Move to the folder where you want to create your portlet and run

mvn archetype:generate

From the list select liferay-portlet-archetype and provide your project groupId, artifactId and version for the portlet project.

You're portlet project's pom.xml has two properties liferay.auto.deploy.dir and liferay.version. These properties are usually moved to your parent pom.xml or settings.xml so that you don't have to adjust them for every single plugin you create. Set the liferay.auto.deploy.dir to point to the Liferay autodeploy directory of your Liferay bundle. This is where the deploy plugin will copy your portlet. Now you are ready deploy your newly created portlet. You can deploy it by running

mvn liferay:deploy

6. Future Plans

We are also in the process of adding archetypes for themes, hooks and layouts as well as providing portlet archetypes for different types of portlets like JSP, Spring MVC, JSF etc. I will blog about it once they are done.

A special thanks goes to Thiago Moreira and Brian Chan for making this possible. Also for the community and customers for putting pressure to have this done.

If you are using 5.2.3 CE and want to take advantage of Maven for building Liferay portlets Milen Dyankov a Liferay community member has done also great work on a Maven SDK for 5.2.3 CE. You can find more about it from GitHub

]]>
Starting to recover from jetlag after a two week trip Los Angeles and Liferay retreat. One of the things we finally made some progress during the developer retreat  is providing official maven artifacts for Liferay as well as porting our plugins sdk to Maven. Things are not quite completed but I will provide some instructions here for all early adopters.

So our goal is to provide our CE releases through our own public repository as well as provide means for our EE customers to install the EE versions artifacts to their local maven repository.

If you have ever worked with enterprise projects using maven you already know how important a local maven repository and proxy is. For those not so familiar with Maven a proxy is a server that proxies your requests to public Maven repositories and caches the artifacts locally for faster and more reliable access. Most maven proxies can also host private repositories used for hosting your company’s private artifacts. Having a local proxy / repository makes your maven builds much faster and more reliable than accessing remote repositories that might even sometimes be unavailable.

1. Installing a maven proxy / repository

First step is to install and setup Nexus. Nexus is a open source maven repository manager that can proxy to other repositories as well as host repositories. If you just want to try things locally you can skip this step.

  1. Download latest Nexus such as nexus-webapp-1.4.0-bundle.zip
  2. Follow the installation directions of the Nexus book http://nexus.sonatype.org/documentation.html
  3. Startup nexus
  4. Open your browser to your newly created nexus (if you installed it locally it could be accessed by opening http://localhost:8080/nexus)
  5. Login as administrator (default login is admin / admin123)
  6. Go to Repositories and click Add -> Hosted Repository
  7. Give the repository following information and click save
    • Repository ID: liferay-ce-releases
    • Repostory Name: Liferay CE Release Repository
    • Provider: Maven2 Repository
    • Repository Policy: Release
  8. Create another hosted repository with following information
    • Repository ID: liferay-ce-snapshots
    • Repository Name: Liferay CE Snapshot Repository
    • Provider: Maven2 Repository
    • Repository Policy: Snapshot

Now you have a repository ready for Liferay’s Maven artifacts. Next step is to configure your maven to be able to upload artifacts to that repository.

 2. Configuring Maven Settings

Open your $HOME/.m2/settings.xml (if the file does not exist create it). Add the servers segment to your settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings>
     <servers>
          <server>
               <id>liferay</id>
               <username>admin</username>
               <password>admin123</password>
          </server>
     </servers>
</settings>

You might also want to make your Nexus as your maven proxy. To do that just add following xml segment to your settings.xml right before servers element.

<mirrors>
     <mirror>
          <id>local</id>
          <name>Local mirror repository</name>
          <url>http://localhost:8080/nexus/content/groups/public</url>
          <mirrorOf>*</mirrorOf>
     </mirror>
</mirrors>

3. Installing Liferay Artifacts to Repository

Next we will install the Liferay Maven artifacts to your repository. First you need to checkout Liferay code from the SVN.

svn --username guest co svn://svn.liferay.com/repos/public/portal/trunk portal-trunk

Guest user does not require password.

Then create a release.${username}.properties file and add

maven.url=http://localhost:8080/nexus/content/repositories/liferay-ce-snapshots

Build Liferay artifacts by running

ant clean start jar

Now you can deploy the Liferay artifacts to your maven repository by running

ant -f build-maven.xml deploy-artifacts

If you only want to have them locally without a maven repository you can run the install task instead of deploy

ant -f build-maven.xml install-artifacts

Now you can add Liferay dependencies to your maven project. Following artifacts are available:

<dependency>
	<groupId>com.liferay.portal</groupId>
	<artifactId>portal-client</artifactId>
	<version>5.3.0-SNAPSHOT</version>
</dependency>
<dependency>
	<groupId>com.liferay.portal</groupId>
	<artifactId>portal-impl</artifactId>
	<version>5.3.0-SNAPSHOT</version>
	<scope>provided</scope>
</dependency>
<dependency>
	<groupId>com.liferay.portal</groupId>
	<artifactId>portal-kernel</artifactId>
	<version>5.3.0-SNAPSHOT</version>
	<scope>provided</scope>
</dependency>
<dependency>
	<groupId>com.liferay.portal</groupId>
	<artifactId>portal-service</artifactId>
	<version>5.3.0-SNAPSHOT</version>
	<scope>provided</scope>
</dependency>
<dependency>
	<groupId>com.liferay.portal</groupId>
	<artifactId>portal-web</artifactId>
	<version>5.3.0-SNAPSHOT</version>
	<scope>provided</scope>
</dependency>
<dependency>
	<groupId>com.liferay.portal</groupId>
	<artifactId>util-bridges</artifactId>
	<version>5.3.0-SNAPSHOT</version>
</dependency>
<dependency>
	<groupId>com.liferay.portal</groupId>
	<artifactId>util-java</artifactId>
	<version>5.3.0-SNAPSHOT</version>
</dependency>
<dependency>
	<groupId>com.liferay.portal</groupId>
	<artifactId>util-taglib</artifactId>
	<version>5.3.0-SNAPSHOT</version>
</dependency>
NOTE portal-impl and portal-web are provided for maven plugins and should never be added as dependency to your Liferay plugins.

 4. Installing the Liferay Maven SDK

To take full advantage of Maven we are porting the functionality of out ant based Plugins SDK to Maven. To use it you need to install it locally. To install the Liferay maven plugins and archetypes go into support-maven folder and run

mvn install

Now the Liferay Maven SDK is installed and ready to use. We’ve implemented a portlet archetype and deployer plugin.

5. Creating a Portlet Plugin

Move to the folder where you want to create your portlet and run

mvn archetype:generate

From the list select liferay-portlet-archetype and provide your project groupId, artifactId and version for the portlet project.

You’re portlet project’s pom.xml has two properties liferay.auto.deploy.dir and liferay.version. These properties are usually moved to your parent pom.xml or settings.xml so that you don’t have to adjust them for every single plugin you create. Set the liferay.auto.deploy.dir to point to the Liferay autodeploy directory of your Liferay bundle. This is where the deploy plugin will copy your portlet. Now you are ready deploy your newly created portlet. You can deploy it by running

mvn liferay:deploy

6. Future Plans

We are also in the process of adding archetypes for themes, hooks and layouts as well as providing portlet archetypes for different types of portlets like JSP, Spring MVC, JSF etc. I will blog about it once they are done.

A special thanks goes to Thiago Moreira and Brian Chan for making this possible. Also for the community and customers for putting pressure to have this done.

If you are using 5.2.3 CE and want to take advantage of Maven for building Liferay portlets Milen Dyankov a Liferay community member has done also great work on a Maven SDK for 5.2.3 CE. You can find more about it from GitHub

This post was originally published on Liferay blog.

]]>
286