You can take full advantage of Maven in Liferay Dev Studio with its built-in Maven support. In this article, you’ll learn about the following topics:
- Installing Maven Plugins for Liferay Dev Studio
- Importing Maven Projects
- Using the POM Graphic Editor
First you’ll install the necessary Maven plugins for Dev Studio.
To support Maven projects in Dev Studio properly, you first need a mechanism to recognize Maven projects as Dev Studio projects. For Dev Studio to recognize the Maven project and for it to be able to leverage Java EE tooling features (e.g., the Servers view) with the project, the project must be a flexible web project. Dev Studio relies on the following Eclipse plugins to provide this capability:
m2e(Maven integration for Eclipse)
m2e-wtp(Maven integration for WTP)
All you have to do is install them so you can begin developing Maven projects for Liferay DXP.
When first installing Dev Studio, the installation startup screen asks if you want to install the Maven plugins automatically. Don’t worry if you missed this during setup. You’ll learn how to install the required Maven plugins for Dev Studio manually below.
Navigate to Help → Install New Software. In the Work with field, insert the following value:
Check the Liferay IDE Maven Support option. This bundles all the required Maven plugins you need to begin developing Maven projects for Liferay DXP.
If the Liferay IDE Maven Support option does not appear, then it’s already installed. To verify that it’s installed, uncheck the Hide items that are already installed checkbox and look for Liferay IDE Maven Support in the list of installed plugins. Also, if you want to view everything that is bundled with the Liferay IDE Maven Support option, uncheck the Group items by category checkbox.
Click Next, review the install details, accept the term and license agreements, and select Finish.
Awesome! Your Dev Studio is ready to develop Maven projects for Liferay DXP!
You’ll learn about importing Maven projects in Dev Studio next.
To import a pre-existing, non-Liferay Maven project into Dev Studio, follow the steps outlined below:
Navigate to File → Import → Maven → Existing Maven Projects and click Next.
Click Browse… and select the root folder for your Maven project. Once you’ve selected it, the
pom.xmlfor that project should be visible in the Projects menu.
Now your Maven project is available from the Package Explorer. To import a Liferay project built with Maven, see the Importing Projects in Dev Studio Next you’ll learn about Dev Studio’s POM graphical editor.
You’re provided a graphical POM editor when opening your Maven project’s
pom.xml in Dev Studio. This gives you several different ways to leverage
the power of Maven in your project:
Overview: provides a graphical interface where you can add to and edit the
Dependencies: provides a graphical interface for adding and editing dependencies in your project, as well as modifying the
dependencyManagementsection of the
Effective POM: provides a read-only version of your project POM merged with its parent POM(s),
settings.xml, and the settings in Eclipse for Maven.
Dependency Hierarchy: provides a hierarchical view of project dependencies and an interactive listing of resolved dependencies.
pom.xml: provides an editor for your POM’s source XML.
The figure below shows the
pom.xml file editor and its modes.
By taking advantage of these interactive modes, Dev Studio makes modifying and organizing your POM and its dependencies a snap!