The latest milestone release of Liferay IDE (2.0 Milestone-1) contains support for Liferay maven projects that use the liferay-maven-plugin to build their Liferay projects. Specifically a maven project configurator has been added to support configuraing projects as a full Liferay IDE projects (adding liferay. facets)
Liferay developers that would like to use Maven to build their Liferay plugin projects can use a various of maven related mojo-plugins. However, the official Liferay supported way, specifically for plugins projects (only plugin projects, general portal is not included) is to use a the liferay-maven-plugin mojo for building/deploying plugins. For creating new liferay maven-plugin projects, several liferay plugin type maven archetypes all available in maven plugin central. Each of these liferay maven archetypes will add the liferay-maven-plugin in the pom.xml build plugin configuration section. Most of the Liferay plugins are just war packages with the liferay-maven-plugin added to their configuration sections.
Liferay IDE Support #
In order to properly support these types of projects in Liferay IDE, we first need a mechanism to recognize these projects as Liferay IDE projects. Liferay IDE projects are recognized in Eclipse as faceted web projects that include the appropriate Liferay plugin facet. Therefore all liferay IDE projects are also Eclipse web projects (faceted project with web facet installed). First, in order to get maven projects to be recognized by Eclipse and work with the other JEE tooling, such as the Servers view, they must be flexible web projects as well. So in order to facilitate both of these requirements (flexible web projects with liferay facet installed), m2e-liferay requires these additional Eclipse plugin dependencies.
- m2e-core (Maven integration for Eclipse)
- m2e-wtp (Maven integration for WTP)
First m2e-core is the standard Maven tooling support for Eclipse and is available from Eclipse.org web site as a plugin. The main benefits it provides is dependency resolution classpath management and also abstract project configuration framework for adopters. Secondly, in order for the Liferay projects using maven to be recognized as flexible web projects, we must use another plugin from Eclipse, m2e-wtp. This provides a project configuration mapping between the war package types POMs in maven model to the flexible web project support in Eclipse. With this in place, the only remaining piece to make Liferay maven plugins first-class Eclipse citizens is making sure that m2e-core can recognize the extra lifecycle metadata mappings that are required to support the custom liferay:xyz goals in the liferay-maven-plugin mojos. In the latest release, m2e-core plugin requires that it be explicitly told how to integrate plugins such as liferay-maven-plugin that contribute goals to the standard build lifecycle, via a liferay-metadata-execution mapping. Normally Eclipse m2e-core users would have to specify these manually themselves. However, the m2e-liferay plugin we have now created, automatically provides this mapping saving the user from having to do anything to their project configuration. Also we can provide m2e-core with additional build participation in order to make sure that Liferay maven plugins are handled properly in the Eclipse build lifecycle. (e.g. making sure that liferay:build-css is called for theme deployments, etc).
Using m2e-liferay #
- First download the 2.0 Milestone-1 build http://releases.liferay.com/tools/ide/latest/milestone/.
- Next install the m2e-liferay feature (this requires m2e-core and m2e-wtp as dependencies).
- If you already have m2e-core or m2e-wtp installed, you may be prompted for upgrading to the latest m2e-core (1.4.0) and m2e-wtp (1.0.0).
m2e-core project configurators #
Here I need to give you a quick note about m2e-core project configurators. Any time the user's maven project configuration changes in any way (project import, pom.xml change, manually executed), m2e-core will perform some basic configuration of any maven project (turning pom.xml into .project and .classpath). But at the end of this process it will also execute all registered project configurators. These project configurators extend the m2e-core import process to materialize the maven object model into a working Eclipse project (transfer metadata from pom.xml to .settings/). m2e-liferay contributes a new project configurator that will try to recognize Liferay maven plugin projects and properly configure them as Liferay IDE Projects (flexible web projects that have liferay plugin facets installed). Also, users can create new maven project using the liferay--archetypes form maven central. But this really just repeats the import process. First m2e-core will delegate to maven to create the project from the archetype and then it will automatically start the project configurator transformation process.
Liferay Project update #
Once everything is installed, the first thing is to try to get your Liferay maven plugins recognized as Liferay IDE projects. The next steps you need to do depend on how your existing Liferay Maven plugin is configured.
- Liferay project is already Eclipse flexible web project (m2e-wtp is already installed and has configured the web facet on your project)
In this case you simply need to just re-run the Maven update project action to re-run the m2e-core project configuration process. Right-click your Liferay project, choose Maven > Update project...
- Liferay project is open in Eclipse but it isn't a maven project in Eclipse (m2e nature).
In this case you need to re-import your project into Eclipse just like for the first time. First delete your existing project from Eclipse (Don't delete the contents from disk!). Then use the Maven Import wizard, File > Import > Maven > Existing maven project into workspace)
- You don't have your project in Eclipse at all.
In this case simply run the Maven import project wizard for the first time, File > Import > maven > existing maven project into workspace
m2e-liferay project configuration #
No matter which method above you used to configure your Liferay maven plugin, eventually m2e-core will delegate project configuration of your Liferay maven plugin to the m2e-liferay project configurator. First the m2e-wtp project configurator will execute which will convert your Liferay war package into an Eclipse flexible web project. Next, the m2e-liferay configurator will execute and first it is going to look for the liferay-maven-plugin to be registered on the pom effective model for war type packages. If no liferay-maven-plugin is configured on the effective pom for the project, then the project configuration will not continue. If the liferay-maven-plugin has been specified, the following settings must be specified:
In m2e-core there are various ways to satisfy specifying these properties. In the pom.xml directly, in a parent pom, or in a maven profile. Once you have a maven profile configured (in settings.xml) you can active this profile in m2e-core property page. Right-click on project -> properties, go to maven, in the profiles textfield, type in the profiles ids that supply the necessary settings.
Once all of these values are specified the m2e-liferay configurator will double check to make sure the values for all of these settings point to valid values (make sure if it points to a directory that it actually exists, etc). If the configurator finds any errors it will mark the user's pom.xml with errors. If you need to fix one of the values, to update it to valid value, then you can re-run the project configuration process by right-clicking project, maven > update project....
Project Update #
After your pom configuration meets the requirements, the m2e-liferay configurator will install the Liferay plugin facet, and congratulations, now your project is a full-fledged Liferay IDE project. Which means that all wizards, editors, etc will work as expected! Also, now you can drag-n-drop to publish your project to the Liferay Portal servers in the servers view.
There is no specific new Liferay project wizard for maven yet, however, you can use the existing New Maven Project wizard and specify the Liferay plugin archetype and once the underlying maven project has been created, then the project configurators will execute including m2e-liferay. However, in most cases these new projects wont yet meet all the configuration requirements (appServerXYZ settings haven't been specified yet), so you will have to update them and then re-run the Maven > Update project action.
Known Issues #
With this 2.0 Milestone-1 build there are several known issues related to m2e-liferay plugin:
- Selecting hook properties in New Hook Wizard doesn't work with maven-based projects
- Ext archetype deployment is not yet supported through server publishing mechanimsm