« Zurück zu Plugins SDK

Plugin to extend a plugin

Asset-Tag: extension 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 Anhänge
34887 Angesehen
Durchschnitt (9 Stimmen)
Die durchschnittliche Bewertung ist 4.666666666666667 von max. 5 Sternen.
Kommentare
Antworten im Thread Autor Datum
I've been working with Liferay for 3 years and... Rubén García Tamayo 16. September 2012 08:16
Great! I thought it was only valid for themes.... Mauro Mariuzzo 16. September 2012 08:40
For maven users. If you are maven developer you... Sampsa Sohlman 16. September 2012 12:30
Do you have an example for that maybe? I would... Marco Endres 21. April 2015 00:31
Good to know this...didn't know this at all :)... Jay Patel 18. September 2012 11:33
Great feature Julio . Most of the liferay... Gnaniyar Zubair 19. September 2012 04:55
Nice feature Julio and thanks for sharing. ... Glenn Saler 19. September 2012 08:53
It's awesome heature Julio Satish Babu Anupoju 27. September 2012 18:38
Its a good feature to know.Most of the times we... Srikanth Reddy 28. September 2012 05:14
This is really awesome, Thank you very much... Nagendra Kumar Busam 2. Oktober 2012 08:25
Nice feature. I thought it works only for theme :) Kailash Yadav 7. April 2013 03:47
Gr8 to know that way to fix up things. dave ch 24. September 2013 08:23
I tried to changes calendar-portlet in... Munikanta Singh 12. Juni 2014 06:25
Also java files can be changed by they need to... Mauro Mariuzzo 13. Juni 2014 02:43
Thanks its work !! Now I can able to changes... Munikanta Singh 19. Juni 2014 00:47

I've been working with Liferay for 3 years and I never take a look over this feature. It's a cool trick.
Gepostet am 16.09.12 08:16.
Great!

I thought it was only valid for themes....
Gepostet am 16.09.12 08:40.
For maven users. If you are maven developer you can use maven war plugin and shade plugin to achieve task.
Gepostet am 16.09.12 12:30.
Good to know this...didn't know this at all emoticon Thanks for sharing this..
Gepostet am 18.09.12 11:33.
Great feature Julio .

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

will try it out and update if any
Gepostet am 19.09.12 04:55.
Nice feature Julio and thanks for sharing. WIll get the word out!
Gepostet am 19.09.12 08:53.
Gepostet am 27.09.12 18:38 als Antwort auf Glenn Saler.
Its a good feature to know.Most of the times we skip it and try hard to work with Hooks.
Thanks Julio
Gepostet am 28.09.12 05:14 als Antwort auf Satish Babu Anupoju.
This is really awesome, Thank you very much sharing emoticon
Gepostet am 02.10.12 08:25.
Nice feature. I thought it works only for theme emoticon
Gepostet am 07.04.13 03:47.
Gr8 to know that way to fix up things.
Gepostet am 24.09.13 08:23.
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 ?
Gepostet am 12.06.14 06:25.
Also java files can be changed by they need to have the same name and placed in the same folder structure
Gepostet am 13.06.14 02:43.
Thanks its work !! Now I can able to changes the java file
Gepostet am 19.06.14 00:47 als Antwort auf Mauro Mariuzzo.
Do you have an example for that maybe? I would be nice emoticon I tried it, but it didn't work. thank you.
Gepostet am 21.04.15 00:31 als Antwort auf Sampsa Sohlman.