For Liferay plugins, you can create a new plugin that extends an existing one. By extending a plugin, you can use all its features in your new plugin while keeping your changes/extensions separate from the existing plugin’s source code.
To create a plugin that extends another, follow these steps:
Create a new empty plugin in the Plugins SDK. Visit the Developing with the Plugins SDK tutorials for information on how to develop plugins using the Plugins SDK.
Remove all the auto-generated files except
build.xmland the docroot folder, which should be empty.
Copy the original WAR file of the plugin you’d like to extend (e.g.,
social-networking-portlet-126.96.36.199.war) to the root folder of your new plugin.
Add the following line to your
<project>tag to reference the original WAR file you are going to extend:
<property name="original.war.file" value="social-networking-portlet-188.8.131.52.war" />
Copy any files from the original plugin that you’re overwriting to your new plugin (using the same folder structure) and run the Ant target
merge. Please note that the
mergetarget is called whenever the plugin is compiled. All you have to do is check the Ant output:
[email protected]:~/sdk/portlets/my-social-networking-portlet$ ant war Buildfile: /home/user/sdk/portlets/my-social-networking-portlet/build.xml compile: merge: [mkdir] Created dir: /home/user/sdk/portlets/my-social-networking-portlet/tmp [mkdir] Created dir: /home/user/sdk/portlets/my-social-networking-portlet/tmp/WEB-INF/ classes [mkdir] Created dir: /home/user/sdk/portlets/my-social-networking-portlet/tmp/WEB-INF/ lib merge-unzip: [unzip] Expanding: /home/user/sdk/portlets/my-social-networking-portlet/social- networking-portlet-184.108.40.206.war into /home/dsanz/sdk/ portlets/my-social-networking-portlet/tmp [copy] Copying 2 files to /home/user/sdk/portlets/my-social-networking-portlet/tmp [mkdir] Created dir: /home/user/sdk/portlets/my-social-networking-portlet/docroot/ WEB-INF/classes ...
If the plugin that you’re extending contains a service, you need to overwrite the
ClpSerializer.javafile. The Service Builder-generated
ClpSerializer.javafile contains a hard-coded project for
_servletContextName. You need to change this to the name of your plugin.
This generates a plugin (you can find the WAR file in the
/dist folder of your plugins SDK) which combines the original one with your changes.