Creating a Liferay Workspace with Blade CLI

In this tutorial, you’ll learn how to generate a Liferay Workspace using Blade CLI. The Blade CLI tool you installed in the Installing Blade CLI section provides many different commands to help build and customize Liferay projects. The first thing you should do before building and customizing projects is create a Liferay Workspace. The workspace generated by Blade CLI is Gradle based; if you’d like to generate a Liferay Workspace built with Maven, see the Maven Workspace tutorial.

Your workspace is the home for all your custom Liferay projects. Navigate to the folder where you want your workspace and run the following command:

blade init -v 7.0 [WORKSPACE_NAME]

Initializing a workspace requires no downloading or access to the internet.

If you still plan on using a Plugins SDK and wish to use it in conjunction with a workspace, navigate to your Plugins SDK root folder and run the following command:

blade init -u

This command builds a workspace and automatically adds and configures your current Plugins SDK environment for use inside the workspace. See the Using a Plugins SDK From Your Workspace section for more information on how to use a Plugins SDK from within a workspace.

Once your workspace is generated, look at its folder structure. Several folders and build/properties files were autogenerated:

  • configs
  • gradle
  • modules
  • themes
  • build.gradle
  • gradle-local.properties
  • gradle.properties
  • gradlew
  • settings.gradle

The build/properties files included in your workspace’s root directory sets your workspace’s Gradle properties and facilitates the build processes of your modules. You can learn more about these generated files/folders in the Liferay Workspace tutorial. You’ll learn about how to use these folders and properties files throughout the next few tutorials.

Next you’ll learn about generating and using a Liferay DXP instance from within your workspace.

Running a Liferay Instance from Your Workspace

As discussed in the Liferay Workspace tutorial, Liferay Workspaces can generate and hold a Liferay Server. This lets you build/test your plugins against a running Liferay instance. Once you’ve properly generated and installed a Liferay server in your workspace, you can begin using it with the Blade CLI. To start your Liferay instance, run

blade server start -b

This command starts your Liferay server in a separate window. You also have the option to run your server in debug mode (-d).

Awesome! You have a built-in Liferay server in your workspace and can start the server using Blade CLI. Next you’ll learn how to use a legacy Plugins SDK from your workspace.

Configuring a Plugins SDK in Your Workspace

Because Liferay DXP 7.0 uses a module-based framework, the current structure of a Liferay Workspace is centered around module development. There are still, however, many situations where you must create WAR-style plugins using the Plugins SDK. Because of this, your workspace can also work with the Plugins SDK. When configuring your SDK in a workspace, you can take advantage of all the new functionality workspaces provide and also use the SDK environment that you’re used to.

Running the blade init -u command converted the Plugins SDK to a workspace that includes the Plugins SDK. If you created your workspace from scratch instead with blade init, you’ll need to configure your Liferay workspace’s Gradle properties.

If you revisit your workspace’s gradle.properties file, you’ll notice the Plugins SDK folder is set to plugins-sdk. This folder was not generated by default, so you must create it yourself. In your workspace’s root folder, create the plugins-sdk folder. Then copy your legacy Plugins SDK files into the plugins-sdk folder. Lastly, generate its requirements by running gradlew tasks. Once this command successfully downloads all your Plugins SDK dependencies, it’s ready to use in your workspace. For more information on manually configuring a Plugins SDK, see the Using a Plugins SDK from Your Workspace section.

« Installing Blade CLI with Proxy RequirementsCreating Projects with Blade CLI »
¿Fue útil este artículo?
Usuarios a los que les pareció útil: 0 de 0