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:
- Create a new empty plugin in the Plugins SDK
- Remove all the auto generated files except build.xml and the docroot folder which should be empty
- 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-18.104.22.168-ee-ga1.war)
- 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-22.214.171.124-ee-ga1.war" />
- 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-126.96.36.199-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.