« Back to Plugins SDK

Plugin to extend a plugin

For Liferay plugins, it is possible to take an existing plugin and create another one that extends the original one keeping your changes separated from the plugin source code.

In order to create a plugin which extends another, you just need to follow these steps:

  1. Create a new empty plugin in the Plugins SDK
  2. Remove all the auto generated files except build.xml and the docroot folder which should be empty
  3. Copy inside of the root folder of your new plugin the original WAR of the plugin you want to extend (for example, social-networking-portlet-6.1.10.1-ee-ga1.war)
  4. Add the following line to your build.xml inside of the tag <project> in order to reference the original war file you are going to extend.
    <property name="original.war.file" value="social-networking-portlet-6.1.10.1-ee-ga1.war" />
  5. Add any files you want to add or overwrite from the original plugin in your plugin (following the same folder structure) and run the ant target merge. Please note that the merge target is called whenever the plugin is compiled. All you have to do is to check the ant output:
dsanz@host:~/sdk/portlets/my-social-networking-portlet$ ant war
Buildfile: /home/dsanz/sdk/portlets/my-social-networking-portlet/build.xml

compile:

merge:
    [mkdir] Created dir: /home/dsanz/sdk/portlets/my-social-networking-portlet/tmp
    [mkdir] Created dir: /home/dsanz/sdk/portlets/my-social-networking-portlet/tmp/WEB-INF/classes
    [mkdir] Created dir: /home/dsanz/sdk/portlets/my-social-networking-portlet/tmp/WEB-INF/lib

merge-unzip:
    [unzip] Expanding: /home/dsanz/sdk/portlets/my-social-networking-portlet/social-networking-portlet-6.1.10.1-ee-ga1.war into /home/dsanz/sdk/portlets/my-social-networking-portlet/tmp
     [copy] Copying 2 files to /home/dsanz/sdk/portlets/my-social-networking-portlet/tmp
    [mkdir] Created dir: /home/dsanz/sdk/portlets/my-social-networking-portlet/docroot/WEB-INF/classes

...

This will generate a plugin (you can find the WAR file in the /dist folder of your plugins SDK) which combines the original one plus your changes.

0 Attachments
14322 Views
Average (8 Votes)
The average rating is 5.0 stars out of 5.
Comments
Threaded Replies Author Date
I've been working with Liferay for 3 years and... Rubén García Tamayo September 16, 2012 8:16 AM
Great! I thought it was only valid for themes.... Mauro Mariuzzo September 16, 2012 8:40 AM
For maven users. If you are maven developer you... Sampsa Sohlman September 16, 2012 12:30 PM
Good to know this...didn't know this at all :)... Jay Patel September 18, 2012 11:33 AM
Great feature Julio . Most of the liferay... Gnaniyar Zubair September 19, 2012 4:55 AM
Nice feature Julio and thanks for sharing. ... Glenn Saler September 19, 2012 8:53 AM
It's awesome heature Julio Satish Babu Anupoju September 27, 2012 6:38 PM
Its a good feature to know.Most of the times we... Srikanth Reddy September 28, 2012 5:14 AM
This is really awesome, Thank you very much... Nagendra Kumar Busam October 2, 2012 8:25 AM
Nice feature. I thought it works only for theme :) Kailash Yadav April 7, 2013 3:47 AM
Gr8 to know that way to fix up things. dave ch September 24, 2013 8:23 AM
I tried to changes calendar-portlet in... Munikanta Singh June 12, 2014 6:25 AM
Also java files can be changed by they need to... Mauro Mariuzzo June 13, 2014 2:43 AM
Thanks its work !! Now I can able to changes... Munikanta Singh June 19, 2014 12:47 AM

I've been working with Liferay for 3 years and I never take a look over this feature. It's a cool trick.
Posted on 9/16/12 8:16 AM.
Great!

I thought it was only valid for themes....
Posted on 9/16/12 8:40 AM.
For maven users. If you are maven developer you can use maven war plugin and shade plugin to achieve task.
Posted on 9/16/12 12:30 PM.
Good to know this...didn't know this at all emoticon Thanks for sharing this..
Posted on 9/18/12 11:33 AM.
Great feature Julio .

Most of the liferay developers dont aware of this feature . Thanks for sharing.

will try it out and update if any
Posted on 9/19/12 4:55 AM.
Nice feature Julio and thanks for sharing. WIll get the word out!
Posted on 9/19/12 8:53 AM.
It's awesome heature Julio
Posted on 9/27/12 6:38 PM in reply to Glenn Saler.
Its a good feature to know.Most of the times we skip it and try hard to work with Hooks.
Thanks Julio
Posted on 9/28/12 5:14 AM in reply to Satish Babu Anupoju.
This is really awesome, Thank you very much sharing emoticon
Posted on 10/2/12 8:25 AM.
Nice feature. I thought it works only for theme emoticon
Posted on 4/7/13 3:47 AM.
Gr8 to know that way to fix up things.
Posted on 9/24/13 8:23 AM.
I tried to changes calendar-portlet in liferay6.2 JSP file which is working perfectly fine but when I tried to change the java class file like say CalendarPortlet it is not working.

Have any idea how to change that java class file ?
Posted on 6/12/14 6:25 AM.
Also java files can be changed by they need to have the same name and placed in the same folder structure
Posted on 6/13/14 2:43 AM.
Thanks its work !! Now I can able to changes the java file
Posted on 6/19/14 12:47 AM in reply to Mauro Mariuzzo.