A Liferay Maven Workspace is a generated environment that is built to hold and manage Liferay projects built with Maven. This workspace aids in Liferay project management by applying various Maven plugins and configured properties. The Liferay Maven Workspace offers a full development lifecycle for your Maven projects to make developing them for Liferay DXP easier than ever. In this tutorial, you’ll learn how to leverage the development lifecycle of a Liferay Maven Workspace.
First, you’ll learn how to install a Maven Workspace.
The Maven Workspace is installed by generating the workspace project from either an archetype or via Blade CLI. You can generate a workspace via archetype by executing the following command:
mvn archetype:generate \ -DarchetypeGroupId=com.liferay \ -DarchetypeArtifactId=com.liferay.project.templates.workspace \ -DgroupId=[GROUP_ID] \ -DartifactId=[WORKSPACE_NAME] \ -Dversion=[VERSION]
If you have Blade CLI installed, and want to use that instead of generating an archetype, you can run the following command:
blade init -b maven [WORKSPACE_NAME]
A Maven Workspace is generated in the current folder. No other tools or CLIs are required for Maven Workspace.
The default Maven Workspace contains the following folders/files:
For more information on the
configs folder, see the
wars folders hold projects of that type.
pom.xml configures your workspace as a Maven project and applies
Bundle Support plugin,
which is required for your Maven Workspace to handle Liferay DXP 7.1 projects. You
configure workspace properties in
your POM, which you’ll learn about later.
Next, you’ll learn how to initialize and package Liferay DXP bundles using workspace.
Liferay Maven Workspaces can generate and hold a Liferay Server. This lets you
build/test your plugins against a running Liferay instance. Before generating a
Liferay instance, open the
pom.xml file located in your workspace’s root
folder and set the version of the Liferay bundle to generate and install by
setting the download URL for the
liferay.workspace.bundle.url property. For
<properties> <liferay.workspace.bundle.url> https://releases-cdn.liferay.com/portal/7.1.0-ga1/liferay-ce-portal-tomcat-7.1.0-ga1-20180703012531655.zip </liferay.workspace.bundle.url> ... </properties>
You can also set location of your Liferay bundle with the
liferay.workspace.home.dir property. It’s set to
bundles by default.
Important: Make sure the
com.liferay.portal.tools.bundle.support plugin in
your POM is configured to use version
liferay.workspace.bundle.url property does not work for workspaces using an
older version of the Bundle Support plugin. See the
Updating a Maven Workspace section for
instructions on how to update the plugin.
Once you’ve finalized your workspace properties, navigate to your workspace’s root folder and run
blade server init
This uses workspace’s pre-bundled
Blade CLI tool to download
the version of Liferay DXP you specified in your POM file and installs your
Liferay DXP instance in the
bundles folder. If you prefer to not use Blade CLI
or do not have it installed, the pure Maven equivalent for this command is
If you want to skip the downloading process, you can create the
manually in your workspace’s ROOT folder and extract your Liferay Portal bundle
to that folder.
You can also produce a distributable Liferay DXP bundle (Zip) from within a workspace. To do this, navigate to your workspace’s root folder and run the following command:
Your distribution file is available from the workspace’s
There are some configurable workspace properties you can set in the root
liferay.workspace.bundle.url: the URL used to download the Liferay DXP bundle. For more information, see Adding a Liferay Bundle to a Maven Workspace.
liferay.workspace.environment: the name of a
configssubfolder holding the Liferay DXP server configuration to use. See Testing Modules for more information.
Properties can be set by adding tags with the property name. See the property configurations below for an example on how these can be set in your POM:
<properties> <liferay.workspace.bundle.url>https://releases-cdn.liferay.com/portal/7.1.0-ga1/liferay-ce-portal-tomcat-7.1.0-ga1-20180703012531655.zip</liferay.workspace.bundle.url> <liferay.workspace.environment>local</liferay.workspace.environment> </properties>
Next, you’ll learn how to add and deploy modules/projects in your Maven Workspace.
Maven Workspace makes managing your Maven project easier than ever. To create
a project, navigate to the appropriate workspace folder for that type of project
wars, etc.). Then generate the project archetype. You can
view a full listing of the available archetypes in the
reference section. Once the project is generated, it can leverage all of Maven
Maven Workspace also lets you deploy your projects to Liferay DXP using Maven. See the Deploying a Project Built with Maven to Liferay DXP tutorial for more information.
Want to leverage Maven Workspace’s testing infrastructure so you can simulate your Maven projects in a specific environment? See the Testing Modules section for more information.
Once you have your Maven projects solidified and ready for the limelight, it’d be great to release your projects to the public. Maven Workspace doesn’t provide this functionality, but there are easy ways to use external release tools with workspace. See the Releasing Modules section for more information.
Next, you’ll learn how to update a Maven Workspace.
Liferay Workspace is updated periodically with new features, so you’ll want to
update your workspace instance accordingly. To update your Maven Workspace, you
must update the Bundle Support plugin configured in your workspace’s root
<plugin> <groupId>com.liferay</groupId> <artifactId>com.liferay.portal.tools.bundle.support</artifactId> <version>3.2.5</version> ... </plugin>
Update the version to the latest available release. You can reference the available releases for the Bundle Support plugin here.