Liferay's artifact are now Mavenized

  Hi there!

  We are glad to announce for all those of you Maven adicted like me , that now Liferay has its artifacts public in a Maven 2 repository! The community request was listened and answered.

  The repository contains artifacts of version 6.0.2 and 6.0.3. The deployed artifacts are:

Core projects:

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

Maven plugins:

  • liferay-layouttpl-archetype
  • liferay-maven-plugin
  • liferay-portlet-archetype
  • liferay-theme-archetype

   The repository is http://oss.sonatype.org/content/groups/public you can have access to release and snapshot versions of the artifacts. The snapshots artifacts are build and deploy once a day.  

  To use it you should reference it in your POM (you can also set the repository information in your settings.xml file) and declare your dependencies, like the sample that follows. The artifacts are being synced with Central, so you don't need to declare the repository if you are not using SNAPSHOT versions.

 <project>
   ...

   <repositories>
        <repository>
            <id>liferay-repository</id>
            <name>Liferay's Maven repository</name>
            <url>http://oss.sonatype.org/content/groups/public</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>com.liferay</groupId>
            <artifactId>portal-service</artifactId>
            <version>6.0.3</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    ...
</project>

  Then you can use all the Maven functionality to manage your development.

  This is one more step to get closer to the Maven community, so let us know if you have questions/ideas/suggestions and please enjoy!!!

  Um abraço!

p.s. Liferay's dream #2 completed :-)

Blogs
Cool. I'd like to see an option when creating an ext plugin to use maven. Or just a standard pom file next to the ant script inside ext.zip.
Thanks, great work emoticon

Would it be realistic to hope having the portal war stored into the maven repository?

I know that it's quite heavy but it's wonderful to use with the war overlay capability of maven for quickly cleanly and easily creating customized wars of the portal...
That's great news. I do not need to search for the jar file and deploy to my own repository any more. However, I cannot see the jar files in the maven2 repository. I see only 4.2.1 source. Were they deployed?

Brian
Hey Brian,

You should be able to see them here: http://repo2.maven.org/maven2/com/liferay/
Maybe your browser has cached the page... but all artifacts are there.
Great I see the files at central
Should there also be pom.xml files in http://svn.liferay.com/repos/public/portal/trunk /... ?
How would/should my local mvn setting.xml look like then? My local mvn setting.xml also points to a mirror local nexus with sonar stuff (see below). Does it make sense to add the above the way I have added below to make my new mvn build of custom liferay portlets work?

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/Users/yeongsheng/sdk/mvn/repo</localRepository>
<interactiveMode>true</interactiveMode>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*,!sonar</mirrorOf>
<name>Sambaash Maven Cloud CI Server Nexus.</name>
<url>http://sit.sambaash.com:8180/nexus/content/groups/public</url>
</mirror>

<mirror>
<id>liferay-repository</id>
<mirrorOf>*</mirrorOf>
<name>Liferay's Maven repository</name>
<url>http://oss.sonatype.org/content/groups/public</url>
</mirror>
</mirrors>

<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the build in central report to direct all requests to nexus via the mirror-->
<repositories>
<repository>
<id>central</id>
<name>Repository for Sambaash Platform 2.0 Builds</name>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
<!--<snapshotPolicy>always</snapshotPolicy>-->
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
Hi Yeong,

You don't need to add Liferay's repository because the artifacts are available at central.
But I am getting errors with my mvn compile for Liferay Vaadin project. My project pom.xml as below:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sambaash.platform</groupId>
<artifactId>Sambaash-Vaadin</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>Sambaash Vaadin Portal Application</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<sourceDirectory>src</sourceDirectory>
<outputDirectory>war/WEB-INF/classes</outputDirectory>
<defaultGoal>deploy</defaultGoal>
<finalName>Sambaash-Vaadin</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>vaadin-snapshots</id>
<url>http://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin</artifactId>
<version>6.4.1</version>
</dependency>
<dependency>
<groupId>com.liferay</groupId>
<artifactId>portal-service</artifactId>
<version>6.0.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

Error I am getting is:

Yeong-Shengs-MacBook-Pro:Sambaash-Vaadin yeongsheng$ mvn compile
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Sambaash Vaadin Portal Application
[INFO] task-segment: [compile]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/yeongsheng/repo/sambaash.corporate.vaadin/Sambaash-Vaadin/src/main/resources
Downloading: http://sit.sambaash.com:8180/nexus/content/groups/public/com/liferay/portal-service/6.0.2/portal-service-6.0.2.pom
[INFO] Unable to find resource 'com.liferay:portal-service:pom:6.0.2' in repository central (http://central)
Downloading: http://sit.sambaash.com:8180/nexus/content/groups/public/com/liferay/portal-service/6.0.2/portal-service-6.0.2.jar
[INFO] Unable to find resource 'com.liferay:portal-service:jar:6.0.2' in repository central (http://central)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) com.liferay:portal-service:jar:6.0.2

Try downloading the file manually from the project website.

Then, install it using the command:
mvn install:install-file -DgroupId=com.liferay -DartifactId=portal-service -Dversion=6.0.2 -Dpackaging=jar -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=com.liferay -DartifactId=portal-service -Dversion=6.0.2 -Dpackaging=jar -Dfile=/path/to/file -Durl= -DrepositoryId=[id]

Path to dependency:
1) sambaash.platform:Sambaash-Vaadin:war:1.0
2) com.liferay:portal-service:jar:6.0.2

----------
1 required artifact is missing.

for artifact:
sambaash.platform:Sambaash-Vaadin:war:1.0

from the specified remote repositories:
nexus (http://sit.sambaash.com:8180/nexus/content/groups/public)



[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Wed Aug 11 00:17:16 SGT 2010
[INFO] Final Memory: 9M/265M
[INFO] ------------------------------------------------------------------------
Sorry, my pom.xml again as below:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sambaash.platform</groupId>
<artifactId>Sambaash-Vaadin</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>Sambaash Vaadin Portal Application</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<sourceDirectory>src</sourceDirectory>
<outputDirectory>war/WEB-INF/classes</outputDirectory>
<defaultGoal>deploy</defaultGoal>
<finalName>Sambaash-Vaadin</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>vaadin-snapshots</id>
<url>http://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin</artifactId>
<version>6.4.1</version>
</dependency>
<dependency>
<groupId>com.liferay</groupId>
<artifactId>portal-service</artifactId>
<version>6.0.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Error received is:

Missing:
----------
1) com.liferay:portal-service:jar:6.0.2

Try downloading the file manually from the project website.

Then, install it using the command:
mvn install:install-file -DgroupId=com.liferay -DartifactId=portal-service -Dversion=6.0.2 -Dpackaging=jar -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=com.liferay -DartifactId=portal-service -Dversion=6.0.2 -Dpackaging=jar -Dfile=/path/to/file -Durl= -DrepositoryId=[id]

Path to dependency:
1) sambaash.platform:Sambaash-Vaadin:war:1.0
2) com.liferay:portal-service:jar:6.0.2

----------
1 required artifact is missing.

for artifact:
sambaash.platform:Sambaash-Vaadin:war:1.0

from the specified remote repositories:
nexus (http://sit.sambaash.com:8180/nexus/content/groups/public)
Think I might have found the issue; The sample pom.xml dependency provided above missed out portal in the groupId. i.e. it should be com.liferay.portal instead of com.liferay only for groupId def provided.

The corrected sample should look:
<project>
...

<repositories>
<repository>
<id>liferay-repository</id>
<name>Liferay's Maven repository</name>
<url>http://oss.sonatype.org/content/groups/public</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<version>6.0.3</version>
<scope>provided</scope>
</dependency>
</dependencies>

...
</project>
This is excellent development.

Thank you for making our life little easier.
Thiago, I did found couple of bugs, the first one is easily fixed (LPS-12090) and solution is there, but second one (LPS-12095) is littlebit more complicated.
This is the best thing that's happened since discovering liferay! Great thanks to all who contributed to the devlopment of a liferay sdk maven plugin and getting everything up on Central! Having just tried out some of the archetypes and deploying with the plugin, I must say I am one happy developer!

Thanks again!
I just tried using the liferay-theme-archetype and generated a maven project. Without changing anything I ran liferay:deploy and it successfully was pushed out to my local copy of liferay; however, when I looked at the available themes it was not there. It was listed under Portlet Plugins. Has anyone had any success building and deploying a theme using the liferay-theme-archetype? I am trying to determine if there is something that I missed.
Hi Robert... Did you happen to do a mvn package or mvn install before running liferay:deploy goal? I'm guessing maybe the liferay:theme-merge goal was not run but I could be wrong about this. What I've done is bind the liferay:deploy goal to the package phase in my build as the archetype came with liferay:theme-merge and liferay:build-thumbnail already bound to the generate-sources phase.

btw: I'm using 6.0.5, not sure if that helps you out in any way.
Robert,
What is the name of the file? I heard that Liferay recognizes it as a theme only when the file name includes "theme" in it.

Brian
Brian, I created another project from the liferay-theme-archetype and named the artifact [project]-theme. This fixed the problem.
Hi, Thiago,

It looks like the source code is updated now. After I follow the steps you explained, I got build error as it cannot locate the liferay-lib-5.2.3-r2.pom. Do you know where I can find this pom file?
Thank you.

Brian
Hei Brian,

I believe that you are talking about liferay maven sdk made by Milen Dyankov

https://github.com/azzazzel/liferay-maven-sdk/

- Sampsa

- Sampsa
Hi Sampsa,

Maybe you are right. However, I followed the instruction on this article to create a project and end up with pom.file like following. Since there is no liferay-lib-5.2.3-r2.pom, I cannot go further. Can you guess what I did wrong?
Thank you.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>liferay</groupId>
<artifactId>sample</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Maven Portlet Archetype</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>com.commsen.liferay</groupId>
<artifactId>liferay-lib</artifactId>
<version>5.2.3-r2</version>
<scope>provided</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>

<properties>
<service.api.folder>src/main/java-service-api</service.api.folder>
</properties>

<profiles>
<profile>
<id>default profile</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>translate</id>
<activation>
<property>
<name>translate</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.commsen.liferay</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>translate</goal>
</goals>
<configuration>
<langDir>${basedir}/src/main/resources/content</langDir>
<langFile>Language</langFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>build-service</id>
<activation>
<property>
<name>build-service</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.commsen.liferay</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>build-service</goal>
</goals>
<configuration>
<serviceApiFolderName>${service.api.folder}</serviceApiFolderName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>service builder profile</id>
<activation>
<file>
<exists>src/main/webapp/WEB-INF/service.xml</exists>
</file>
</activation>
<dependencies>
<dependency>
<groupId>com.commsen.liferay.portal.libraries</groupId>
<artifactId>util-java</artifactId>
<version>5.2.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${service.api.folder}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Now that I have had the pleasure to begin planning a new project based on liferay and have played a bit with the portlet and theme archetypes, I'm wondering if anyone could offer up any advice, tips/tricks in regards to rapid theme and portlet development in a maven environment? The archetypes and the mojos work wonderfully for getting a new project started and deployed to liferay, however it is the slow process of not being able to see changes until the project is deployed to liferay that is a killer for a team of developers. Does anyone know how a developer might make theme changes and see them immediately in a browser before deploying to liferay? Any input on this subject would be greatly appreciated!

Thanks in advance,
-Ryan
Hi Ryan,

I am doing same kind of project. But I am having an issue to create a maven project with proper dependencies. I wonder if you can post or email (bko@behr.com) the pom.xml file created by portlet archetype. As you can see on my post, mine has a dependency to the pm file I cannot find. Thank you in advance.

Brian
Hi Brian,
I would be happy to help you out however I am running LR 6.0.5 and it would appear that artifacts started getting deployed to maven central at version 6.0.2 (as stated by the OP). The dependency you are trying to fetch does not exist in central (http://www.jarvana.com/jarvana/search?search_type=project&project=liferay). This being said, I believe Sampsa is right in that for pre-6.0.2 versions your maven options pretty much boil down to azzazzel's implementation.

Hope that helps,
-Ryan
Hi Ryan,

I followed the process described in http://www.liferay.com/community/wiki/-/wiki/Main/Liferay+Maven+SDK. It ends up with portlet with the 5.2.3 dependencies. I guess that is the problem. Have you followed differest steps to create your project?
Thank you.
Brian
Brian:
If you are using maven 2.x or higher (m3) you should not need to add any repositories to nexus or to your settings.xml. If you have, my best bet is that you can undo everything that thread tells you to do in regards to configuring the liferay repos as everything needed to create and deploy portlets/themes/hooks is present in maven central for versions 6.0.2-6.0.5. Once you've removed the liferay repo configuration simply invoke a "mvn archetype:generate" and enter the number that corresponds to the archetype you wish to use to create your project. I've used both the theme and portlet archetypes successfully for version 6.0.5.

HTH,
-Ryan
Thiago:
I've begun creating a maven plugin that will emulate the tomcat-maven-plugin's "run" goal that combined with the liferay maven portlet archetype will allow for rapid portlet development in an embedded tomcat container. I was hoping to use the portal-web-6.0.5.war artifact currently present in maven central but it would appear that this artifact lacks all but one of the 178 dependencies found in the war obtained from the "Additional Files" download page of the liferay 6 war. Is there any reason why the war's dependencies are not present in the maven artifact and are there any future plans of making the portal-web.war maven artifact deployable w/out the consumer having to find 177 additional dependencies and manually copying them to the WEB-INF/lib directory? I'm currently working around this issue by deploying the working war file obtained from the "Additional Files" download page to our internal Nexus repo but was hoping users of the plugin would not have to do the same.

Could you offer any information on this? Any feedback at all would be GREATLY appreciated and want you to know that I have every intention of contributing this plugin to the community.

Thanks in advance,
-Ryan
I think the reason for these 177 dependencies are not there is that they are provided (all ready on the server CP) the way liferay originally works.

A solution could be to make a pom-artifact with all these dependencies and then depend on it as "provided", and it would be solid maven. Then you could overload the dependency "local" without provided.
Anders:
Thanks for your reply. I have no doubt that the portal-web artficact's POM is declaring its dependencies as provided but I would have to argue that this is not the correct use of the provided scope. Provided scope is typically used to declare a dependency that is required for compilation that the web/app container already provides (servlet-api for example). I have yet to see a container (tomcat, jetty, etc) that comes bundled with spring, easyconf, etc so I would maintain that most of the dependencies that the portal-web project declares as provided are actually compile and/or runtime dependencies. The versions of these dependencies are meant for portal-web and it should not be assumed that all other wars running in the same container (portlets, etc) use the same version of spring for example. This is not a container provided dependency. It seems ridiculous to me to expect a consumer of this war to be able to determine not only WHAT 177 dependencies are missing but what VERSION of each dependency is missing. I would think that some dependencies could certainly be provided scope but I'm guessing most should really be bundled with the deployed war artifact upon release to central.

Looking forward to other's input.

Thanks,
-Ryan
Hey Ryan,

The reason for not have these dependencies is that Liferay is not built by Maven and the pom generated is the simplest as possible.
Thanks, Thiago. This makes more sense. I'm guessing maybe the maven ant tasks are being used in this case then? Any plans on updating in future releases to include all dependencies in the released artifact? As it stands, the war is more or less unusable from central w/out some additional work.

Thanks for the reply!
-Ryan
Forgot to mention that I would be MORE than happy to contribute some time to the effort of getting the portal-web pom into a more accurate state. Anything I might do to help with this effort?

-Ryan
Hi Thiago

Actually this also means that it is impossible example to create ext-plugin support for maven as Liferay internal dependencies are not published.

- Sampsa
[...] Maybe this helps https://github.com/mikakoivisto/liferay-maven-incubation http://www.liferay.com/web/thiago.moreira/blog/-/blogs/liferay-s-artifact-are-now-mavenized... [...] Read More
Hello
I've just started working with liferay and building portlets, and have found this post via my google travells for maven and liferay 6.0.5. I've read hints of things regrading a maven-liferay-sdk from 2009 and various posts about creating or using the liferay-portlet-archetype but I'm still not sure who to continue. Is there a tutorial that explains what is possible and how to do it? I'm specifically interested in
1) How to build a portlet using the liferay-portlet-archetype using maven
2) Can the liferay IDE be used to build portlets using the same maven set up but also deploy using maven?
thanks for any pointers
Hi n b,

1) you should create a portlet project from a archetype as you would create for any other archetype.
2) No, Liferay IDE does not support Maven until now.
Where are the transitive dependencies defined? 6.0.6, maven-war-plugin overlay to portal-web and I'm stuck having to copy all the jars to my web-inf lib...
Hey Albert,

Liferay is not built by Maven so we don't have the tracking of transitive dependencies.
It is unfortunate, Liferay is not build by maven itself...
What about test and test-sources artifacts? For example, if I want tod evelop tests for services and I want to use
com.liferay.portal.service.BaseServiceTestCase
I still do not have any chance to do it without sharing the whole portal stuff into the mavenized project or do something similar...