Deploying Projects with Blade CLI

Deploying projects to a Liferay server using Blade CLI is easy. To use the Blade deploy command, you must first have built a project to deploy. See the Creating Projects with Blade CLI tutorials for more information about creating Liferay projects. Once you’ve built a project, navigate to it with your CLI and execute the following command to deploy it:

blade deploy

This can be used for WAR-style projects and modules (JARs). You can also deploy all projects in a folder by running the deploy command from the parent folder (e.g., [WORKSPACE_ROOT]/modules).

If you’re using Liferay Workspace, the deploy command deploys your project based on the build tool’s deployment configuration. For example, leveraging Blade CLI in a default Gradle Liferay Workspace uses the underlying Gradle deployment configuration. The build tool’s deployment configuration is found by reading the Liferay Home folder set in your workspace’s gradle.properties or pom.xml file. The deploy command works similarly if you’re working outside of workspace; the Liferay Home folder, in contrast, is set by loading the Liferay extension object (Gradle) or the effective POM (Maven) and searching for the Liferay Home property stored there. If it’s not stored, Blade prompts you to set it so it’s available.

If you prefer not to use your underlying build tool’s (Gradle or Maven) module deployment configuration, and instead, you want to deploy straight to Liferay DXP’s OSGi container, run this command instead:

blade deploy -l

Blade CLI also offers a way to watch a deployed project, which compiles and redeploys a project when changes are detected. There are two ways to do this:

  • blade watch
  • blade deploy -w

The blade watch command is the fastest way to develop and test module changes, because the watch command does not rebuild your project every time a change is detected. When running blade watch, your project is not copied to Portal, but rather, is installed into the runtime as a reference. This means that the Portal does not make a cached copy of the project. This allows the Portal to see changes that are made to your project’s files immediately. When you cancel the watch task, your module is uninstalled automatically.

The watch task does not work with JSF portlets or fragment projects.

The blade deploy -w command works similarly to blade watch, except it manually recompiles and deploys your project every time a change is detected. This causes slower update times, but does preserve your deployed project in Portal when it’s shut down.

Cool! You’ve successfully deployed your module project using Blade CLI.

« Creating Projects with Blade CLIManaging Your Liferay Server with Blade CLI »
Was this article helpful?
0 out of 0 found this helpful