Showing posts with label maven. Show all posts
Showing posts with label maven. Show all posts

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

Friday, July 22, 2016

Maven ServiceBuilder stop override portlet-model-hints.xml with lifeary

Hello Liferay Experts,

Here i am sharing some important liferay + maven information. which i got after spending my more then half day, it may help you as well.

This is helpful for those who are working with liferay 6.1 + service builder  + maven build tool. some time you need to change DB field size rather then default size which generate from service builder code.

Obviously liferay expert very well know to change  portlet-model-hints.xml  to increase filed size. if you don't know about that then this is importance for you, you need to change that file. it's famous and well known problem with maven is overriding your portlet-model-hints.xml everytime while you build service. please check MAVEN-37 and LPS-10607 links for reporting @ liferay.

Due to this you want be able to change your filed size because if you change that file and getting that reflect you need service build. as i said earlier service build is again override your changes if you do build service. to overcome/resolve this issue here i come up with workaround and few step to follow....

1.  Your maven portlet parent pom.xml configure the liferay maven plugin for version 6.1.30 like              bellow...
    <build>
<plugins>
<plugin>
                       <groupId>com.liferay.maven.plugins</groupId>
             <artifactId>liferay-maven-plugin</artifactId>
             <version>6.1.30</version>
             .....

        </plugin>
     </plugins>
   </build>

2. Maven portlet parent pom.xml also have entry in dependency for above liferay maven plugin.

     <dependencies>
<dependency>
   <groupId>com.liferay.maven.plugins</groupId>
   <artifactId>liferay-maven-plugin</artifactId>
   <version>6.1.30</version>
</dependency>
</dependencies>


3. Make sure maven porlet all three pom.xml refer the same configuration version of liferay maven     plugin. suppose you have maven portlet name portlet-test then check below files

    -porlet-test/pom.xml
    -porlet-test/portlet-test-porlet/pom.xml 
    -porlet-test/portlet-test-portlet-service/pom.xml

4. Update portlet-model-hints.xml with your required changes something like

    <field name="message" type="String">
<hint-collection name="TEXTAREA" />
    </field>

5. Rebuild service.xml and deploy porlet then check your DB table wether your changes get reflect or     not. i am sure yes it is.

6. Make smiley face.....


Hope this save someone development time and make them relax...!!

Thank you.

NOTE : 
I am working with maven 6.1.2 and liferay 6.1.2 and above solution is perfectly working fine with mentioned version.


Thanks,
Ketan Savaliya