Developing Liferay Hook Plugins with Maven

Hooks are the optimal plugin type for customizing Liferay’s core features. Creating a hook plugin with Maven is very similar to creating a portlet plugin with Maven. This tutorial explains how to create a hook plugin and explains the Liferay Maven hook plugin project’s anatomy.

Creating a Hook Plugin

To create a Liferay hook plugin project, follow the steps outlined in the Creating Liferay Maven Plugins from Liferay IDE tutorial or the Creating Liferay Maven Plugins from the Command Line tutorial, making sure to select Hook as the plugin type.

Since it’s helpful to familiarize yourself with the Liferay hook plugin project’s anatomy, that topic is covered next.


A hook project created from the com.liferay.maven.archetypes:liferay-hook-archetype has the following directory structure:

  • hook-plugin/
    • src/
      • main/
        • java/
        • resources/
        • webapp/
          • WEB-INF/
            • lib/ * Optionally add to hold required libraries
            • liferay-hook.xml
            • web.xml
    • pom.xml

The hook-plugin/src/main/java/ directory holds the hook’s Java source code (e.g., and hook-plugin/src/main/webapp holds the hook’s web source code. If you’re familiar with creating hook plugins using the Plugins SDK, you’ve probably noticed that Maven uses a different plugin directory structure.

The following table illustrates the differences in location of the Java source and web source code for a Maven project and a Plugins SDK project:

Location | Maven project | Plugins SDK project | ———– | —————– | ——————— | Java source | src/main/java | docroot/WEB-INF/src | Web source | src/main/webapp | docroot |

You now know how to create Liferay hook plugins to customize Liferay.

Deploying Liferay Plugins with Maven

Customizing Liferay Portal

« Developing Liferay Theme Plugins with MavenDeveloping Liferay Layout Template Plugins with Maven »
Este artigo foi útil?
Utilizadores que acharam útil: 0 de 0