This post describes the process of Migrating Liferay EXT plugin projects from SDK to Maven. Maven EXT plugins are set up as multi-module Maven projects. Migrating from the SDK to Maven is pretty easy, but there are some things that you need to be aware of.
Creating the Project
To create the new project, use the “liferay-ext-archetype”. Defining the group id and version is up to you, but the artifact id should not have a “-ext” suffix; the submodules will have appropriate suffixes added for you.
The Submodules
There will be nine submodules in your new EXT plugin. The following table shows the suffix and the purpose of the submodule:
Submodule Suffix | Description |
---|---|
-ext | This submodule will contain the target directory where the deployable war artifact is found. |
-ext-impl | This submodule will contain override classes for the portal-impl classes. |
-ext-lib-global | This submodule is used to deploy new global jars to the application container. |
-ext-lib-portal | This submodule is used to deploy new jars to the portal’s WEB-INF/lib directory. |
-ext-service | This submodule will have override classes or new service classes for the portal. |
-ext-util-bridges | This submodule will have overrides or extensions for the util-bridges jar. |
-ext-util-java | This submodule will have overrides or extensions for the util-java jar. |
-ext-util-taglib | This submodule will have overrides or extensions for the util-taglib jar. |
-ext-web | This submodule will have overrides or extensions to the Liferay portal web application (JSP overrides, static file overrides, etc.). |
Copying Files
Files must be copied from the SDK project to the new Maven project. The table below identifies the SDK source folder and the corresponding target folder in the Maven project:
Source | Target Suffix |
---|---|
docroot/WEB-INF/ext-impl | -ext-impl |
docroot/WEB-INF/ext-service | -ext-service |
docroot/WEB-INF/ext-util-bridges | -ext-util-bridges |
docroot/WEB-INF/ext-util-java | -ext-util-java |
docroot/WEB-INF/ext-util-taglib | -ext-util-taglib |
docroot/WEB-INF/ext-web | -ext-web |
Note that when copying the files, Java sources go into the submodule’s src/main/java folder, non-java sources go into src/main/resources and, if applicable, web files will go into src/main/webapp. The Maven archetype will create the folders that should be populated for each submodule.
Global and Portal Jars
Maven doesn’t like local jars. It likes to pull dependencies from the repository and include them as necessary. The global and portal jars deployed via the EXT plugin are no different.
To include one or more jar files for deployment to the global or portal libs, you edit the appropriate pom.xml file and simply add the dependency (do not use provided scope). Any dependencies listed will be included in the EXT deployable war artifact. At deployment time, these files will be copied to the appropriate location (either the global or portal lib directory).
Building
From the main project folder, executed the mvn package command to build the EXT deployable war. If successful, the war file will be in the “-ext” subproject’s target directory. This is the war file that should be copied to the Liferay deploy directory.
Note that just like EXT plugins developed using the SDK, EXT plugins cannot be redeployed or undeployed from a Liferay instance.