Friday, 26 October 2012

Creating a plugin to extend other plugin



Creating a plugin to extend other plugin
This is a great feature of Liferay plugins which I come across. It has been available since 4.3. If you find a plugin that you like but you would like to modify something, you can create another plugin which extends the original one keeping your changes isolated from the original one.
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. Take original WAR of the plugin you want to extend, place outside of docroot folder (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" />
  1. Add any files you want to add or overwrite from the original plugin in your plugin (following the same folder structure of your original) 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:
  2. 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.
  3. Just deploy and see the changes

No comments:

Post a Comment