Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
constantin köck
New Liferay Maven Plugin
April 22, 2011 8:58 AM
Answer

constantin köck

Rank: New Member

Posts: 16

Join Date: June 20, 2010

Recent Posts

Hi,
I am not an expert on maven but since today the first version of the new maven implementation of the plugins sdk (with ext and hook) was released i wanna give this a try and some feed back to the author...

I downloaded the file from here:
https://github.com/mikakoivisto/liferay-maven-incubation/

Installation of the archetypes worked quite well but everything seems to be configured for liferay 6.1.0 ...

I would like to use the maven plugin for 6.0.6 ...

Can someone give me a hint what i have to change in the pom.xml files ? (I changed the liferay version property to 6.0.6-snapshot but this has no effect)..

regards
c
Mika Koivisto
RE: Liferay Maven Plugin
April 22, 2011 9:58 AM
Answer

Mika Koivisto

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1513

Join Date: August 7, 2006

Recent Posts

After you checkout the project you need to replace every occurrence of 6.1.0-SNAPSHOT with 6.0.6 in every single pom.xml including the ones inside the archetypes src/main/resources/archetype-resources. Once you've done that you can run mvn install. Now I don't know for sure if everything is compatible with 6.0.6 as I haven't tested it with it. At least you need to create a new portal-web artifact that contains all libs in WEB-INF/lib.
constantin köck
RE: Liferay Maven Plugin
April 22, 2011 10:15 AM
Answer

constantin köck

Rank: New Member

Posts: 16

Join Date: June 20, 2010

Recent Posts

Thanks for your fast response.... i will try this tomorrow and give feedback
Hitoshi Ozawa
RE: Liferay Maven Plugin
April 22, 2011 4:50 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Mika,

I heard sometimes ago that Liferay was thinking of moving over to github. The site below seems to be your site or is this the official Liferay site?

https://github.com/mikakoivisto/liferay-maven-incubation/
Hitoshi Ozawa
RE: Liferay Maven Plugin
April 22, 2011 4:52 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Thanks for your fast response.... i will try this tomorrow and give feedback
.

Will greatly appreciate if you can share with us the files you've changed after you've made it work. emoticon
Mika Koivisto
RE: Liferay Maven Plugin
April 22, 2011 5:05 PM
Answer

Mika Koivisto

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1513

Join Date: August 7, 2006

Recent Posts

That is my personal github site. I'm currently mirroring the commits to svn portal/trunk/support-maven once I think it's done. We'll be also moving to github pretty soon and then I'm hoping to establish a separate code base for maven stuff. Until then this is the place to check out for latest maven stuff.

My own maven usage has dwindled down quite a bit since I don't do customer projects anymore so I need feedback on what is needed from people using maven actively with Liferay.
Hitoshi Ozawa
RE: Liferay Maven Plugin
April 22, 2011 5:11 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Thank you for the quick reply. Will be looking forward to it.
Will try out the repository at your site when I make some time. emoticon
Jelmer Kuperus
RE: Liferay Maven Plugin
April 23, 2011 12:26 AM
Answer

Jelmer Kuperus

Rank: Liferay Legend

Posts: 1192

Join Date: March 10, 2010

Recent Posts

Kind of off-topic, but is there any chance of this becoming the officially endorsed preferred way to do develop plugins.

I think for Liferay maven makes a lot more sense than ant does. And the more i use the liferay-sdk the more i realize how limited it is. eg

- no support for unit testing
- no support for dependency management
- no place to put code shared acoross multple plugin modules (clp services, utils)
- you have to check in the binary jar of your services
- no easy way to ship a plugin without its sources
- no easy way to customize the build
constantin köck
RE: Liferay Maven Plugin
April 25, 2011 2:46 AM
Answer

constantin köck

Rank: New Member

Posts: 16

Join Date: June 20, 2010

Recent Posts

Made some progress (Ext projects seem to work now):

What i did :
As suggested i replaced all 6.0.6 strings in the directory.
Afterwards i had to change the visbility of copyXmls from protected to public in BaseDeployer.java and all its derived classes..

Then i recompiled the portal and installed the artifacts in my local repository as described in:
http://www.liferay.com/de/community/wiki/-/wiki/Main/Liferay+Maven+SDK

Afterwards i was able to use the maven archetypes:
After a quick look the Hook plugin seems to work which is great ...

Then i added some missing dependencies to the liferay mavenplugin and added two lines in the ExtMojo for removing some unused jars from the war.

Afterwards the war deployed correct.
This is just a rough prototype but i think its worth sharing (attache the gzipped directory)
Any feedback is welcome

Thanks Const
Attachments: lmi606.tar.gz (189.4k)
Mika Koivisto
RE: Liferay Maven Plugin
April 25, 2011 5:43 PM
Answer

Mika Koivisto

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1513

Join Date: August 7, 2006

Recent Posts

I feel your pain that is why I started doing this in the first place. Most of the things you list can be accomplished with ant based plugins sdk except real dependency management although with the latest (trunk) version you can have the build even copy the service.jar to from plugins you've declared to be dependent on.

Maven does provide better means for all of those but there are a lot of people that have no clue on how to use maven and it take's longer to learn that the very simple ant based plugins sdk. So I doubt the we'll ever prefer maven over ant but they can and will be equals. Now we have almost all features for maven that we have for plugins sdk.
Mika Koivisto
RE: Liferay Maven Plugin
April 25, 2011 5:48 PM
Answer

Mika Koivisto

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1513

Join Date: August 7, 2006

Recent Posts

Thanks Constantin. I'll take a look at your changes. I'll probably create a separate branch for 6.0.x.

I've committed today installer that creates and installs the liferay artifacts from tomcat bundle and source. It works for 6.0.6 and 6.0 EE. It should help with adding the artifacts locally until my separate maven distribution package passes review and is released.
constantin köck
RE: Liferay Maven Plugin
April 26, 2011 3:37 AM
Answer

constantin köck

Rank: New Member

Posts: 16

Join Date: June 20, 2010

Recent Posts

A seperate branch (i allready created one based on your git repository in the attached gzip) would be great because i think we also need maven in the current version of liferay because thats what people use now and probably for a long time to come ...

regards
c
Jelmer Kuperus
RE: Liferay Maven Plugin
April 26, 2011 6:00 AM
Answer

Jelmer Kuperus

Rank: Liferay Legend

Posts: 1192

Join Date: March 10, 2010

Recent Posts

Most of the things you list can be accomplished with ant based plugins sdk except real dependency management


It's possible to do it with the sdk, but with no real hook points defined, afaik you have to hack and maintain your own copy of the sdk to get basic functionality like junit support
constantin köck
RE: Liferay Maven Plugin
April 28, 2011 1:40 AM
Answer

constantin köck

Rank: New Member

Posts: 16

Join Date: June 20, 2010

Recent Posts

FYI

Mika has put a branch for 6.0.x Portal into his Repository !!!

Thank you and well done !

https://github.com/mikakoivisto/liferay-maven-incubation
Francois Fournel
RE: Liferay Maven Plugin
October 25, 2011 9:35 AM
Answer

Francois Fournel

Rank: Junior Member

Posts: 99

Join Date: April 15, 2010

Recent Posts

Hi Mika,

I'am trying to build your maven plugin (I work with liferay CE 606).
But when building the pom at root, it says :

 1[INFO] Scanning for projects...
 2[WARNING] The POM for org.apache.maven.archetype:archetype-packaging:jar:2.0-alpha-4 is missing, no dependency information available
 3[ERROR] The build could not read 7 projects -> [Help 1]
 4[ERROR]   
 5[ERROR]   The project com.liferay.maven.archetypes:liferay-ext-archetype:6.0.6-SNAPSHOT (G:\helios\workspace-liferay606\liferay-maven-incubation-6.0.x\archetypes\liferay-ext-archetype\pom.xml) has 2 errors
 6[ERROR]     Unresolveable build extension: Plugin org.apache.maven.archetype:archetype-packaging:2.0-alpha-4 or one of its dependencies could not be resolved: The repository system is offline but the artifact org.apache.maven.archetype:archetype-packaging:jar:2.0-alpha-4 is not available in the local repository. -> [Help 2]
 7[ERROR]     Unknown packaging: maven-archetype @ line 13, column 13
 8[ERROR]   
 9[ERROR]   The project com.liferay.maven.archetypes:liferay-hook-archetype:6.0.6-SNAPSHOT (G:\helios\workspace-liferay606\liferay-maven-incubation-6.0.x\archetypes\liferay-hook-archetype\pom.xml) has 2 errors
10[ERROR]     Unresolveable build extension: Plugin org.apache.maven.archetype:archetype-packaging:2.0-alpha-4 or one of its dependencies could not be resolved: The repository system is offline but the artifact org.apache.maven.archetype:archetype-packaging:jar:2.0-alpha-4 is not available in the local repository. -> [Help 2]
11[ERROR]     Unknown packaging: maven-archetype @ line 13, column 13
12[ERROR]   
13[ERROR]   The project com.liferay.maven.archetypes:liferay-layouttpl-archetype:6.0.6-SNAPSHOT (G:\helios\workspace-liferay606\liferay-maven-incubation-6.0.x\archetypes\liferay-layouttpl-archetype\pom.xml) has 2 errors
14[ERROR]     Unresolveable build extension: Plugin org.apache.maven.archetype:archetype-packaging:2.0-alpha-4 or one of its dependencies could not be resolved: The repository system is offline but the artifact org.apache.maven.archetype:archetype-packaging:jar:2.0-alpha-4 is not available in the local repository. -> [Help 2]
15[ERROR]     Unknown packaging: maven-archetype @ line 13, column 13
16[ERROR]   
17[ERROR]   The project com.liferay.maven.archetypes:liferay-portlet-archetype:6.0.6-SNAPSHOT (G:\helios\workspace-liferay606\liferay-maven-incubation-6.0.x\archetypes\liferay-portlet-archetype\pom.xml) has 2 errors
18[ERROR]     Unresolveable build extension: Plugin org.apache.maven.archetype:archetype-packaging:2.0-alpha-4 or one of its dependencies could not be resolved: The repository system is offline but the artifact org.apache.maven.archetype:archetype-packaging:jar:2.0-alpha-4 is not available in the local repository. -> [Help 2]
19[ERROR]     Unknown packaging: maven-archetype @ line 13, column 13
20[ERROR]   
21[ERROR]   The project com.liferay.maven.archetypes:liferay-servicebuilder-archetype:6.0.6-SNAPSHOT (G:\helios\workspace-liferay606\liferay-maven-incubation-6.0.x\archetypes\liferay-servicebuilder-archetype\pom.xml) has 2 errors
22[ERROR]     Unresolveable build extension: Plugin org.apache.maven.archetype:archetype-packaging:2.0-alpha-4 or one of its dependencies could not be resolved: The repository system is offline but the artifact org.apache.maven.archetype:archetype-packaging:jar:2.0-alpha-4 is not available in the local repository. -> [Help 2]
23[ERROR]     Unknown packaging: maven-archetype @ line 13, column 13
24[ERROR]   
25[ERROR]   The project com.liferay.maven.archetypes:liferay-theme-archetype:6.0.6-SNAPSHOT (G:\helios\workspace-liferay606\liferay-maven-incubation-6.0.x\archetypes\liferay-theme-archetype\pom.xml) has 2 errors
26[ERROR]     Unresolveable build extension: Plugin org.apache.maven.archetype:archetype-packaging:2.0-alpha-4 or one of its dependencies could not be resolved: The repository system is offline but the artifact org.apache.maven.archetype:archetype-packaging:jar:2.0-alpha-4 is not available in the local repository. -> [Help 2]
27[ERROR]     Unknown packaging: maven-archetype @ line 13, column 13
28[ERROR]   
29[ERROR]   The project com.liferay.maven.archetypes:liferay-web-archetype:6.0.6-SNAPSHOT (G:\helios\workspace-liferay606\liferay-maven-incubation-6.0.x\archetypes\liferay-web-archetype\pom.xml) has 2 errors
30[ERROR]     Unresolveable build extension: Plugin org.apache.maven.archetype:archetype-packaging:2.0-alpha-4 or one of its dependencies could not be resolved: The repository system is offline but the artifact org.apache.maven.archetype:archetype-packaging:jar:2.0-alpha-4 is not available in the local repository. -> [Help 2]
31[ERROR]     Unknown packaging: maven-archetype @ line 13, column 13
32[ERROR]
33[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
34[ERROR] Re-run Maven using the -X switch to enable full debug logging.
35[ERROR]
36[ERROR] For more information about the errors and possible solutions, please read the following articles:
37[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
38[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException



Can you tell me why ?

My maven repository proxy the maven central repository of course which is : http://repo1.maven.org/maven2/
Why this library (org.apache.maven.archetype:archetype-packaging:jar:2.0-alpha-4) is not retrieved by maven ?

Thanks.
Mika Koivisto
RE: Liferay Maven Plugin
October 25, 2011 11:00 AM
Answer

Mika Koivisto

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1513

Join Date: August 7, 2006

Recent Posts

Looks like your maven failed to download some core maven dependencies. This is one of the downsides of Maven. You can't rely on central being available or consistent. You just have to retry later to see if it's available.
Francois Fournel
RE: Liferay Maven Plugin
October 28, 2011 6:42 AM
Answer

Francois Fournel

Rank: Junior Member

Posts: 99

Join Date: April 15, 2010

Recent Posts

Very sorry, my eclipse "Run configurations" where set to offline by default.
It overrides my settings.xml for maven plugin m2eclipse.
Sorry, all is downloading welll.

Only one access denied :


Access denied to http://repository.jboss.org/maven2/com/sun/media/jai-codec/1.1.3/jai-codec-1.1.3.pom. Error code 403, Forbidden -> [Help 1]

Need to update jboss repo according to http://community.jboss.org/wiki/MavenSettings to http://repository.jboss.org/nexus/content/groups/public/

Plus :

One missing artifact at https://oss.sonatype.org/content/groups/public/com/liferay/portal/portal-impl/6.0.6-SNAPSHOT/ (no jar ressource)

need to correct version of artifact in /liferay-maven-incubation-6.0.x/plugins/liferay-maven-plugin/pom.xml (<version>6.0.6-SNAPSHOT</version> to <version>6.0.6</version>)

Then build is ok (compile at least).

Thx
Francois Fournel
RE: Liferay Maven Plugin
October 31, 2011 8:56 AM
Answer

Francois Fournel

Rank: Junior Member

Posts: 99

Join Date: April 15, 2010

Recent Posts

I ran the build and used the installer to deploy to my nexus repository.
Personnaly, I do it with wagon-ssh (through scp). To be able to deploy to the maven repository (and then reuse those Liferay dependencies for every liferay projects), I did :

1) Installation (or unzip) of Apache Ant somewhere in folder (c:\apache-ant e.g.)

2) Installation (or unzip) of Apache Maven somewhere in folder (c:\apache-maven e.g.)

3) Edit file at artifact-installer-6.0.6-SNAPSHOT\installer.ffournel.properties (= installer.user.properties)

Set the following (in my case) :

 1##
 2## Release info
 3##
 4
 5    lp.version.maven=6.0.6
 6    lp.version=6.0.6
 7
 8##
 9## Maven
10##
11
12    maven.bin.path=C:/Users/ffournel/Desktop/apache-maven-3.0.3-bin/apache-maven-3.0.3/bin/
13    maven.repository.id=liferay-portal-community
14    maven.repository.url=scp://osiris.intuitiv.lan/home/intuitiv-dev/sonatype-work/nexus/storage/liferay-portal-community/
15
16##
17## Liferay
18##
19
20    lp.source.dir=G:/tmp/liferay-portal-src-6.0.6
21    lp.tomcat.dir=G:/liferay-portal-6.0.6-demo/tomcat-6.0.29
22    lp.tomcat.lib.global.dir=${lp.tomcat.dir}/lib/ext
23    lp.tomcat.portal.dir=${lp.tomcat.dir}/webapps/ROOT
24    lp.tomcat.tunnel-web.dir=${lp.tomcat.dir}/webapps/tunnel-web
25
26##
27## Signing
28##
29
30    gpg.bin.path=
31    gpg.keyname=
32    gpg.passphrase=


4) Add the transport protocol to remote repository (= the library) wagon-ssh to maven's classpath. In my case, using Maven 3 to do the deployment of all these Liferay plugins, I downloaded wagon-ssh 2.0 (located at mvnrepository.com), put it into ${M2_HOME/lib/ext}.

5) Edit build.xml of the generated "artifact-installer-6.0.6-SNAPSHOT" doing :

Replace (line 4) <property name="project.dir" value="." />
To an absolute dir (in my case) : <property name="project.dir" value="C:\Users\ffournel\Desktop\artifact-installer-6.0.6-SNAPSHOT-distribution\artifact-installer-6.0.6-SNAPSHOT" />

Replace every lines like
1<exec dir="." executable="${maven.executable}" failonerror="true">

To an absolute dir (in my case) :
1<exec dir="${maven.bin.path}" executable="${maven.executable}" failonerror="true">


6) Correct the syntax bug at
1C:\Users\ffournel\Desktop\artifact-installer-6.0.6-SNAPSHOT-distribution\artifact-installer-6.0.6-SNAPSHOT\poms\tunnel-web.xml

replace the line
1<name>Liferay Tunnel Web<</name>

to
1<name>Liferay Tunnel Web</name>


6) Finally, run
1ant deploy-liferay-artifacts
(put ant, mvn and ssh and scp to your PATH variable environnement. SSH or SCP can be installed with Private Shell for windows)
Fran Serrano Pons
RE: Liferay Maven Plugin
November 25, 2011 7:26 AM
Answer

Fran Serrano Pons

Rank: New Member

Posts: 16

Join Date: October 28, 2011

Recent Posts

Really nice job Mika and Thiago!!
Just starting to give it a try.
I personally think Maven is the way to go, mainly because of dependency management but also because of the evolution it's had since the begining.
The most important thing I find with Maven for Liferay is that dependency to Liferay IDE goes away and anyone is able to use the IDE he likes (in my case IntelliJ)
I'll give feedback ASAP.
Thanks for the great work guys.
Fran Serrano Pons
RE: Liferay Maven Plugin
November 25, 2011 7:41 AM
Answer

Fran Serrano Pons

Rank: New Member

Posts: 16

Join Date: October 28, 2011

Recent Posts

Hi all,
At least with my configuration, liferay-maven-plugin complains about a configuration property. Liferay "version" property is requested:
 1
 2<plugin>
 3                <groupId>com.liferay.maven.plugins</groupId>
 4                <artifactId>liferay-maven-plugin</artifactId>
 5                <version>${liferay.version}</version>
 6                 [color=#f01313]<configuration>[/color]
 7                    <autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>
 8                   [color=#5ba356]<liferayVersion>${liferay.version}</liferayVersion>[/color]
 9                 [color=#f01313]</configuration>[/color]
10</plugin>
David García González
RE: Liferay Maven Plugin
March 19, 2012 3:07 AM
Answer

David García González

Rank: Regular Member

Posts: 127

Join Date: July 14, 2009

Recent Posts

Hi everybody. Is there any documentation about the goals of liferay plugins?

Where could I read about the configuration of these goals. It could be very useful a page like this, where it is explained the goals of "war" with the options to generate the war:

http://maven.apache.org/plugins/maven-war-plugin/index.html