« 返回到 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 附件
34893 查看
平均 (9 票)
满分为 5,平均得分为 4.666666666666667。
评论
讨论主题回复 作者 日期
I've been working with Liferay for 3 years and... Rubén García Tamayo 2012年9月16日 上午8:16
Great! I thought it was only valid for themes.... Mauro Mariuzzo 2012年9月16日 上午8:40
For maven users. If you are maven developer you... Sampsa Sohlman 2012年9月16日 下午12:30
Do you have an example for that maybe? I would... Marco Endres 2015年4月21日 上午12:31
Good to know this...didn't know this at all :)... Jay Patel 2012年9月18日 上午11:33
Great feature Julio . Most of the liferay... Gnaniyar Zubair 2012年9月19日 上午4:55
Nice feature Julio and thanks for sharing. ... Glenn Saler 2012年9月19日 上午8:53
It's awesome heature Julio Satish Babu Anupoju 2012年9月27日 下午6:38
Its a good feature to know.Most of the times we... Srikanth Reddy 2012年9月28日 上午5:14
This is really awesome, Thank you very much... Nagendra Kumar Busam 2012年10月2日 上午8:25
Nice feature. I thought it works only for theme :) Kailash Yadav 2013年4月7日 上午3:47
Gr8 to know that way to fix up things. dave ch 2013年9月24日 上午8:23
I tried to changes calendar-portlet in... Munikanta Singh 2014年6月12日 上午6:25
Also java files can be changed by they need to... Mauro Mariuzzo 2014年6月13日 上午2:43
Thanks its work !! Now I can able to changes... Munikanta Singh 2014年6月19日 上午12: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-9-16 上午8:16 发帖。
Great!

I thought it was only valid for themes....
在 12-9-16 上午8:40 发帖。
For maven users. If you are maven developer you can use maven war plugin and shade plugin to achieve task.
在 12-9-16 下午12:30 发帖。
Good to know this...didn't know this at all emoticon Thanks for sharing this..
在 12-9-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-9-19 上午4:55 发帖。
Nice feature Julio and thanks for sharing. WIll get the word out!
在 12-9-19 上午8:53 发帖。
It's awesome heature Julio
在 12-9-27 下午6:38 发帖以回复 Glenn Saler
Its a good feature to know.Most of the times we skip it and try hard to work with Hooks.
Thanks Julio
在 12-9-28 上午5:14 发帖以回复 Satish Babu Anupoju
This is really awesome, Thank you very much sharing emoticon
在 12-10-2 上午8:25 发帖。
Nice feature. I thought it works only for theme emoticon
在 13-4-7 上午3:47 发帖。
Gr8 to know that way to fix up things.
在 13-9-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-6-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-6-13 上午2:43 发帖。
Thanks its work !! Now I can able to changes the java file
在 14-6-19 上午12:47 发帖以回复 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.
在 15-4-21 上午12:31 发帖以回复 Sampsa Sohlman