Thursday 14 March 2013

Migrate from ant to maven portlet.

1> First of all execute the command : mvn archetype:generate
    When execute this command the option comes to select which kind of the liferay plugin want to make. For example i want to make a service builder then the option withe in value liferay-service then while structure will be generated. In the option we have various option to make maven based hook,ext,portlets.

2> run the command : mvn eclipse:eclise
This will make the code into the project so we can directly import the code into the eclipse.

3> In the ant base portlet we have portlet structure as following.
bookmark-portlet
 |_ docroot
       |_css
       |_js
       |_jsp
       |_meta-inf
       |_web-inf
                |_lib
            |_src
            |_liferay-display.xml
            |_liferay-hook.xml
            |_liferay-plugin-package.properties
            |_liferay-portlet.xml
            |_portlet.xml
            |_web.xml

 |_ build.xml

 For the maven portlet we have following structure.

bookmark-portlet
 |_src
      |_main
            |_java (our java code comes here)
        |_ resource(our property files should come here)        
        |_web-apps
                  |_css
              |_js
              |_jsp
              |_web-inf
                        |_liferay-display.xml
                    |_liferay-hook.xml
                |_liferay-plugin-package.properties
                |_liferay-portlet.xml
                |_portlet.xml
                |_web.xml

For migration from ant portlet to the maven portlet put the all the java classes in to the main.java class. Put al the propertiesis and file of the meta-inf into the resource.


for the service buildes two folders has been generated like

bookmark
     |_bookmark-portlet(All the portlet related classes)
     |_bookmark-service-portlet(All the classes generated by the service builder.)
 |_pom.xml    

4> After doing this run the command mvn clean install it will meke the war into the target folder of the respective portlet. Take a portlet put it into the deploy folder of the tomcat.