Creating Plugins to Extend Plugins

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:

  1. 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.

  2. Remove all the auto-generated files except build.xml and the docroot folder, which should be empty.

  3. Copy the original WAR file of the plugin you’d like to extend (e.g., social-networking-portlet- to the root folder of your new plugin.

  4. Add the following line to your build.xml inside the <project> tag to reference the original WAR file you are going to extend:

  5. 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 merge target is called whenever the plugin is compiled. All you have to do is check the Ant output:

     user@host:~/sdk/portlets/my-social-networking-portlet$ ant war
     [mkdir] Created dir:
     [mkdir] Created dir:
     [mkdir] Created dir:
     [unzip] Expanding:
     networking-portlet- into /home/dsanz/sdk/
     [copy] Copying 2 files to
     [mkdir] Created dir:
  6. If the plugin that you’re extending contains a service, you need to overwrite the file. The Service Builder-generated file 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.

Customizing JSPs by Extending the Original

Overriding and Adding Struts Actions

What is Service Builder?

« Supporting Right-to-Left Languages in PluginsOverriding Portal Properties Dynamically »
Was this article helpful?
0 out of 0 found this helpful