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 IDE 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 IDE’s Code Upgrade Tool adapts traditional plugins to Liferay Portal CE 7.0 APIs. Liferay’s Liferay Theme Generator migrates themes and layout templates to the new NodeJS-based environment and adapts them to Liferay Portal CE 7.0.

Liferay Portal offers you more with Maven too. The archetype Liferay Project Templates Workspace lets you develop in Liferay Workspace using Maven. Liferay Portal CE 7.0‘s’ lean artifacts and new project archetypes and Maven plugins make Liferay Portal 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 Portal CE 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 IDE automatically adapts existing plugins to Liferay Portal CE 7.0. There’s also a tutorial that demonstrates how you can optionally migrate traditional plugins to Workspace.

improved-tooling-code-upgrade-configure-proj.png

Figure 1: Liferay IDE’s Code Upgrade Tool automates many aspects of the plugin upgrade process.

Here’s an example Workspace folder structure:

improved-tooling-workspace-structure.png

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 Portal 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
  • gradle.properties → 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 portal-ext.properties file. Gradle property liferay.workspace.environment in Workspace’s gradle.properties file specifies the configuration to use.

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

Workspace Folder Structure Properties

Property Description
liferay.workspace.environment Name of a configs subfolder holding the Portal server configuration to use
liferay.workspace.home.dir Liferay Portal bundle root folder
liferay.workspace.modules.dir Module projects root folder
liferay.workspace.plugins.sdk.dir Plugins SDK root folder
liferay.workspace.themes.dir Theme projects root folder

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

Plugins SDK to Workspace Task Map

Plugins SDK Ant Target Workspace Gradle Task Task Description
build-css buildCSS Builds CSS files
build-lang buildLang Translates language keys using Language Builder
build-service buildService Runs Service Builder
clean clean Deletes all build outputs
compile classes Compiles classes
deploy deploy (or blade deploy) Installs the current module to Liferay Portal’s module framework
jar jar Compiles the project and packages it as a JAR file
war assemble Assembles project output

Other Workspace Gradle tasks provide additional functionality.

Workspace Gradle Task Task Description
buildSoy Compiles Closure Templates in JavaScript functions
components Lists the project’s components
dependencies Lists the project’s declared dependencies
initBundle Downloads and installs a Liferay Portal bundle
model Lists the project’s configuration model
transpileJS Transpiles 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 com.liferay.docs.mymodule -c MyMvcPortlet my-module

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

improved-tooling-module-wizard.png

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

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

improved-tooling-component-wizard.png

Figure 4: Liferay IDE’s component wizard facilitates creating component classes.

Building and deploying modules in a Workspace is a snap using Liferay IDE 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 IDE lets you deploy modules by dragging them onto your Portal server.

improved-tooling-drag-n-drop-onto-server.png

Figure 5: Liferay IDE 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 IDE, see these tutorials:

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

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

What’s New in Liferay Portal CE 7.0 for Maven Users

Liferay Portal CE 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 Portal CE 7.0 provides many new Maven archetypes for various Liferay module projects. There are over twenty-five Maven archetypes for Liferay Portal CE 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 Portal CE 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 Portal easier than ever. To learn more, see the Maven tutorials.

Using Other Build Systems and IDEs

Liferay Portal 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 has worked hard to make Liferay Portal 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 Portal CE 7.0. Our tools help you upgrade to Liferay Portal CE 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 Portal using other tools is easier than ever. Your tool options are wide open.

+1 (1 Vote)
OSGi and Modularity for Liferay Portal 6 Developers Previous