Thursday, July 28, 2016

Create liferay service builder portlet using maven tool

Hello LRExpert,


Now a days maven as building tool is common practice during development. Lifeary is also support maven tool for building liferay plugin. this article is for those who just start using maven or use maven first to create portlet.

Here i have given steps to create new liferay portlet using maven tool. Please follow simple 11 steps given below.

1) Install Maven
    Find specific liferay maven package for liferay version. here in my case i am using liferay-portal-     6.2-ce-ga6. so, supported liferay maven package is liferay-portal-maven-6.2-ce-ga6.zip. liferay         maven package is nothing but just a zip file. unzip that maven package whenever you want. Insall     maven plugin followed by below steps...

    - Open CMD windows
    - Go to directory location where you just unzip file (i.e liferay-portal-maven-6.2-ce-ga6.zip )
    - Execute command Ant istall
    - Wait untill it's finished execution.
    - You are done with you Liferay Maven Plugin Installation.

2) Go to location in CMD window where you need to create liferay maven portlet (suppose d:/lrproject/Source)
     
3) Execute command : mvn archetype:generate
    This will display list of maven project which you can create like...
     ...
     ...
    221: remote -> com.liferay.maven.archetypes:liferay-ext-archetype (Provides an archetype to create Liferay extensions.)
222: remote -> com.liferay.maven.archetypes:liferay-hook-archetype (Provides an archetype to create Liferay hooks.)
223: remote -> com.liferay.maven.archetypes:liferay-layouttpl-archetype (Provides an archetype to create Liferay layout templates.)
224: remote -> com.liferay.maven.archetypes:liferay-portlet-archetype (Provides an archetype to create Liferay portlets.)
225: remote -> com.liferay.maven.archetypes:liferay-portlet-icefaces-archetype (Provides an archetype to create Liferay ICEfaces portlets.)
226: remote -> com.liferay.maven.archetypes:liferay-portlet-jsf-archetype (Provides an archetype to create Liferay JSF portlets.)
227: remote -> com.liferay.maven.archetypes:liferay-portlet-liferay-faces-alloy-archetype (Provides an archetype to create Liferay Faces Alloy portlets.)
228: remote -> com.liferay.maven.archetypes:liferay-portlet-primefaces-archetype (Provides an archetype to create Liferay PrimeFaces portlets.)
229: remote -> com.liferay.maven.archetypes:liferay-portlet-richfaces-archetype (Provides an archetype to create Liferay RichFaces portlets.)
230: remote -> com.liferay.maven.archetypes:liferay-portlet-spring-mvc-archetype (Provides an archetype to create Liferay Spring MVC portlets.)
231: remote -> com.liferay.maven.archetypes:liferay-servicebuilder-archetype (Provides an archetype to create Liferay Service Builder portlets.)
232: remote -> com.liferay.maven.archetypes:liferay-theme-archetype (Provides an archetype to create Liferay themes.)
233: remote -> com.liferay.maven.archetypes:liferay-web-archetype (Provides an archetype to create Liferay webs.)
...
...
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 817: 231 + Enter [Find your liferay plugin type number from above list and enter it as input for above step]

4) After Enter above steps, it's display liferay version list like...
Choose com.liferay.maven.archetypes:liferay-servicebuilder-archetype version:
1: 6.1.0
2: 6.1.1
3: 6.1.2
4: 6.1.10
5: 6.1.20
6: 6.1.30
7: 6.1.30.1
8: 6.2.0-B1
9: 6.2.0-B2
10: 6.2.0-B3
11: 6.2.0-M5
12: 6.2.0-M6
13: 6.2.0-RC1
14: 6.2.0-RC2
15: 6.2.0-RC3
16: 6.2.0-RC4
17: 6.2.0-RC5
18: 6.2.0-ga1
19: 6.2.1
20: 6.2.2
21: 6.2.4
22: 6.2.5
23: 6.2.10.4
24: 6.2.10.5
25: 6.2.10.6
26: 6.2.10.7
27: 6.2.10.8
28: 6.2.10.9
29: 6.2.10.10
30: 6.2.10.11
31: 6.2.10.12
32: 6.2.10.13
33: 6.2.10.14
34: 6.2.10.15
35: 7.0.0-m1
36: 7.0.0-m2
Choose a number: 36: 19 + Enter [Select liferay version, here i am using 6.2.1 ]

5) Define value for property 'groupId': : com.liferay.portlet.search 
    [project groupid in pom.xml]

6) Define value for property 'artifactId': : my-search-portlet

7) Define value for property 'version':  1.0-SNAPSHOT: : SNAPSHOT-1.0.0 
[Optional...Enter your preferred project version. Other wise default 1.0-SNAPSHOT]

8) Define value for property 'package':  com.liferay.project.search: : com.liferay.project.search
[Optional...Enter your preferred package path. Other wise default com.liferay.project.search]

9) Confirm properties configuration:
     groupId: com.liferay.project.search
     artifactId: my-search-portlet
     version: SNAPSHOT-1.0.0
     package: com.liferay.project.search
     Y: : Y [Enter Y for yest, N for no]

10) your cmd screen final output is....
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: liferay-servicebuilder-archetype:6.2.1
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.liferay.project.search
[INFO] Parameter: artifactId, Value: my-search-portlet
[INFO] Parameter: version, Value: SNAPSHOT-1.0.0
[INFO] Parameter: package, Value: com.liferay.project.search
[INFO] Parameter: packageInPathFormat, Value: com/liferay/project/search
[INFO] Parameter: package, Value: com.liferay.project.search
[INFO] Parameter: version, Value: SNAPSHOT-1.0.0
[INFO] Parameter: groupId, Value: com.liferay.project.search
[INFO] Parameter: artifactId, Value: my-search-portlet
[INFO] project created from Archetype in dir: d:\lrproject\Source\my-search-portlet
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 25:01 min
[INFO] Finished at: 2016-07-28T19:29:27+05:30
[INFO] Final Memory: 16M/229M
[INFO] ------------------------------------------------------------------------

11) Enjoy you are Done. [your maven service builder portlet is create @ d:\lrproject\Source\my-search-portlet]


Veryfirst time you looks it's long process, but once you have more practice to create liferay plugin. then it's very easy to create maven project for liferay.

Hope this Help!!

Thanks,
Ketan Savaliya

No comments:

Post a Comment