Improved Developer Tooling: Liferay Workspace, Maven Plugins and More

Creating applications is fun when you have the right tools. Here are some key ingredients:

  • Rich templates for stubbing out projects
  • Extensible build environments that offer state-of-the-art plugins
  • Deployment and runtime management tools
  • Application upgrade automation

Liferay Workspace (Workspace) boils over with all these things! It’s a Gradle-based development environment that integrates with Liferay Developer Studio and can be used in conjunction with other IDEs, such as a “vanilla” Eclipse, IntelliJ, and NetBeans. You can extend Workspace’s Gradle environment with community-developed (or home-grown) plugins for testing, code coverage analysis, and more.

Workspace comes with Blade CLI: a command line tool for creating and deploying modules, managing the runtime environment, and more. It provides all kinds of module templates, to create modules for developing in any Gradle environment.

Liferay’s tools also streamline the application upgrade process. Liferay Developer Studio’s Upgrade Planner adapts traditional plugins to Liferay DXP 7.0 APIs. Liferay’s Liferay Theme Generator migrates themes and layout templates to the new NodeJS-based environment and adapts them to Liferay DXP 7.0.

Liferay DXP offers you more with Maven too. The archetype Liferay Project Templates Workspace lets you develop in Liferay Workspace using Maven. Liferay DXP 7.0’s’ lean artifacts and new project archetypes and Maven plugins make Liferay DXP development with Maven easier than ever.

Here are the tooling improvement topics:

From the Plugins SDK to Liferay Workspace

The Liferay Plugins SDK is deprecated as of Liferay DXP 7.0. You can continue developing on it, but should plan to eventually move to a new environment. Liferay Workspace succeeds the Plugins SDK as Liferay’s opinionated development environment. You should use it if you’re not using an alternative build system like Gradle or Maven.

Here are Workspace’s key features:

The plugin upgrade tutorials later in this series show how Liferay Developer Studio automatically adapts existing plugins to Liferay DXP 7.0. There’s also a tutorial that demonstrates how you can optionally migrate traditional plugins to Workspace.

Figure 1: Liferay Developer Studios Upgrade Planner automates many aspects of the plugin upgrade process.

Figure 1: Liferay Developer Studio's Upgrade Planner automates many aspects of the plugin upgrade process.

Here’s an example Workspace folder structure:

Figure 2: Liferay Workspace aggregates projects to use the same server configurations and Gradle build environment.

Figure 2: Liferay Workspace aggregates projects to use the same server configurations and Gradle build environment.

Here’s the Workspace anatomy:

  • bundles/ (generated) → default folder for Liferay DXP bundles
  • configs/ → holds Portal server configurations
  • gradle/ → holds the Gradle wrapper files
  • modules/ → holds module projects
  • plugins-sdk/ (generated) → holds plugins from previous releases
  • themes/ → holds NodeJS-based theme projects
  • wars/ (generated) → holds traditional web application projects
  • build.gradle → common Gradle build file
  • → specifies the Portal server configuration and project locations
  • gradlew / gradlew.bat → executes the Gradle command wrapper
  • pom.xml (only in Workspaces generated by Maven) → common Maven build file
  • settings.gradle → applies plugins to the Workspace and configures its dependencies

Workspace module, theme, and war projects use the same Portal server configurations. Developers can create configurations for module development, user acceptance testing, production, and more.

Each subfolder under configs holds a Portal server configuration defined by its file. Gradle property liferay.workspace.environment in Workspace’s file specifies the configuration to use.

Other Gradle properties let you set root locations for the Liferay DXP bundle, modules, themes, and a Plugins SDK.

Workspace Folder Structure Properties

liferay.workspace.environmentName of a configs subfolder holding the Portal server configuration to use
liferay.workspace.home.dirLiferay DXP bundle root folder
liferay.workspace.modules.dirModule projects root folder
liferay.workspace.plugins.sdk.dirPlugins SDK root folder
liferay.workspace.themes.dirTheme projects root folder

Workspace has Gradle tasks equivalent to the Plugins SDK Ant targets.

Plugins SDK to Workspace Task Map

Plugins SDK Ant TargetWorkspace Gradle TaskTask Description
build-cssbuildCSSBuilds CSS files
build-langbuildLangTranslates language keys using Language Builder
build-servicebuildServiceRuns Service Builder
cleancleanDeletes all build outputs
compileclassesCompiles classes
deploydeploy (or blade deploy)Installs the current module to Liferay DXP’s module framework
jarjarCompiles the project and packages it as a JAR file
warassembleAssembles project output

Other Workspace Gradle tasks provide additional functionality.

Workspace Gradle TaskTask Description
buildSoyCompiles Closure Templates in JavaScript functions
componentsLists the project’s components
dependenciesLists the project’s declared dependencies
initBundleDownloads and installs a Liferay DXP bundle
modelLists the project’s configuration model
transpileJSTranspiles the project’s JavaScript files

Next, learn how Workspace facilitates module development.

Developing Modules with Liferay Workspace

Workspace is a great Liferay module development environment because of these features:

  • Templates that bootstrap module creation
  • Gradle and Maven build systems for managing dependencies and assembling modules
  • Module deployment and runtime management capabilities

Blade CLI (Blade), which is a part of Workspace, has over twenty templates for Gradle-based module projects–and more are being added. The templates stub out classes and resource files for you to fill in with business logic and key information.

Here are some of the template’s names:

  • Activator
  • API
  • Content Targeting Report
  • Content Targeting Rule
  • Content Targeting Tracking Action
  • Control Menu Entry
  • MVC Portlet
  • Panel App
  • Portlet
  • Portlet Configuration Icon
  • Portlet Provider
  • Portlet Toolbar Contributor
  • Service
  • Service Builder
  • Service Wrapper
  • Simulation Panel Entry
  • Template Context Contributor

Blade creates modules based on these templates.

For example, the following Blade command creates a Liferay MVC Portlet module called my-module:

blade create -t mvc-portlet -p -c MyMvcPortlet my-module

Liferay Developer Studio’s module project wizard creates Workspace modules from the templates too.

Figure 3: Liferay Developer Studio lets developers select templates to stub out modules.

Figure 3: Liferay Developer Studio lets developers select templates to stub out modules.

Liferay Developer Studio’s component wizard facilitates creating component classes for portlets, service wrappers, Struts actions, and more.

Figure 4: Liferay Developer Studios component wizard facilitates creating component classes.

Figure 4: Liferay Developer Studio's component wizard facilitates creating component classes.

Building and deploying modules in a Workspace is a snap using Liferay Developer Studio and Blade. Workspace uses BndTools to generate each module’s OSGi headers in a META-INF/MANIFEST.MF file. Workspace deploy modules to the OSGi container using Felix File Install commands.

Liferay Developer Studio lets you deploy modules by dragging them onto your Portal server.

Figure 5: Liferay Developer Studio lets you deploy modules using drag-and-drop.

Figure 5: Liferay Developer Studio lets you deploy modules using drag-and-drop.

In a terminal, you can deploy modules using Blade’s deploy command. For example, the following command deploys the current module and “watches” for module changes to redeploy automatically.

blade deploy -w

To learn more about Workspace and using it in Liferay Developer Studio, see these tutorials:

And make sure to check out the tutorial Starting Module Development.

Next, you’ll learn new features for developing on Liferay DXP using Maven.

What’s New in Liferay DXP 7.0 for Maven Users

Liferay DXP 7.0 fully supports Maven development and offers several new and improved features:

  • Liferay Workspace for Maven
  • New archetypes
  • New Maven plugins
  • More granular dependency management

The new archetype Liferay Project Templates Workspace generates a Liferay Workspace that includes a POM file for developing in Workspace using Maven. You can develop modules and themes in the Workspace subfolders.

Liferay DXP 7.0 provides many new Maven archetypes for various Liferay module projects. There are over twenty-five Maven archetypes for Liferay DXP 7.0, and more are in development. Here are some popular ones:

  • Portlets
  • Themes
  • Configuration Icons
  • Menu Buttons
  • Service Builder

Liferay’s Maven archetypes cover many different Liferay frameworks and service types. These make Maven a first-class tool for creating Liferay modules and themes. Visit the Generating New Projects Using Archetypes tutorial to learn more about Liferay’s Maven archetypes and how to use them.

Liferay also provides several new and updated Maven plugins that simplify the build process. The following plugins build style sheets, services, and themes respectively:

Liferay DXP 7.0’s modularity provides a more granular dependency management experience. You no longer need to depend on portal-impl or portal-service (now portal-kernel) for everything. For example, to use Liferay’s Wiki framework, you need only depend on the Wiki module. You set dependencies on concise modules that provide the functionality you want without inheriting extra baggage.

Liferay’s new Workspace environment, Maven archetypes, Maven plugins, and streamlined modules make developing on Liferay DXP easier than ever. To learn more, see the Maven tutorials.

Using Other Build Systems and IDEs

Liferay DXP is tool agnostic–you can use whatever tools you like to develop on it. You can use any IDE and even use Gradle, Bnd, or BndTools if you don’t want to use Workspace. The drawback is you lose the Liferay-specific project templates that you get with Blade and Workspace.

Blade lets you create modules to develop anywhere, not only in Liferay Workspace.

Here are some new Gradle features Liferay provides that are independent of Workspace:

  • Liferay’s Gradle plugins
  • Buildship plugins in Liferay Developer Studio
  • Liferay Developer Studio’s new Gradle views for developing modules and working with Gradle tasks

Liferay has worked hard to make Liferay DXP IDE-agnostic. There are Liferay module developers who use IntelliJ and some enjoy using NetBeans.

Finally, you can copy and modify Liferay sample projects to serve as templates in place of the Blade templates. They’re available for these build systems:

  • Maven
  • Gradle
  • Liferay’s Gradle environment based on the com.liferay.plugin plugin

Liferay’s approach to tooling has vastly improved for Liferay DXP 7.0. Our tools help you upgrade to Liferay DXP 7.0, continue developing traditional plugins the way you have been, and migrate to optimal development environments. Liferay Workspace and the improved Maven support facilitate module development. And developing on Liferay DXP using other tools is easier than ever. Your tool options are wide open.

« OSGi and Modularity for Liferay Portal 6 DevelopersPlanning Plugin Upgrades and Optimizations »