« Plugins SDK に戻る

Plugin to extend a plugin

タグ: 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 添付ファイル
34890 参照数
平均 (9 投票)
平均評価は4.666666666666667星中の5です。
コメント
コメント 作成者 日時
I've been working with Liferay for 3 years and... Rubén García Tamayo 2012/09/16 8:16
Great! I thought it was only valid for themes.... Mauro Mariuzzo 2012/09/16 8:40
For maven users. If you are maven developer you... Sampsa Sohlman 2012/09/16 12:30
Do you have an example for that maybe? I would... Marco Endres 2015/04/21 0:31
Good to know this...didn't know this at all :)... Jay Patel 2012/09/18 11:33
Great feature Julio . Most of the liferay... Gnaniyar Zubair 2012/09/19 4:55
Nice feature Julio and thanks for sharing. ... Glenn Saler 2012/09/19 8:53
It's awesome heature Julio Satish Babu Anupoju 2012/09/27 18:38
Its a good feature to know.Most of the times we... Srikanth Reddy 2012/09/28 5:14
This is really awesome, Thank you very much... Nagendra Kumar Busam 2012/10/02 8:25
Nice feature. I thought it works only for theme :) Kailash Yadav 2013/04/07 3:47
Gr8 to know that way to fix up things. dave ch 2013/09/24 8:23
I tried to changes calendar-portlet in... Munikanta Singh 2014/06/12 6:25
Also java files can be changed by they need to... Mauro Mariuzzo 2014/06/13 2:43
Thanks its work !! Now I can able to changes... Munikanta Singh 2014/06/19 0:47

I've been working with Liferay for 3 years and I never take a look over this feature. It's a cool trick.
投稿日時:12/09/16 8:16
Great!

I thought it was only valid for themes....
投稿日時:12/09/16 8:40
For maven users. If you are maven developer you can use maven war plugin and shade plugin to achieve task.
投稿日時:12/09/16 12:30
Good to know this...didn't know this at all emoticon Thanks for sharing this..
投稿日時:12/09/18 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
投稿日時:12/09/19 4:55
Nice feature Julio and thanks for sharing. WIll get the word out!
投稿日時:12/09/19 8:53
Glenn Salerへのコメント。投稿日時:12/09/27 18:38
Its a good feature to know.Most of the times we skip it and try hard to work with Hooks.
Thanks Julio
Satish Babu Anupojuへのコメント。投稿日時:12/09/28 5:14
This is really awesome, Thank you very much sharing emoticon
投稿日時:12/10/02 8:25
Nice feature. I thought it works only for theme emoticon
投稿日時:13/04/07 3:47
Gr8 to know that way to fix up things.
投稿日時:13/09/24 8: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 ?
投稿日時:14/06/12 6:25
Also java files can be changed by they need to have the same name and placed in the same folder structure
投稿日時:14/06/13 2:43
Thanks its work !! Now I can able to changes the java file
Mauro Mariuzzoへのコメント。投稿日時:14/06/19 0:47
Do you have an example for that maybe? I would be nice emoticon I tried it, but it didn't work. thank you.
Sampsa Sohlmanへのコメント。投稿日時:15/04/21 0:31