Deploying projects to a Liferay server using Blade CLI is easy. To use
deploy command, you must first have built a project to deploy. See
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:
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
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
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 deploy -w
blade watch command is the fastest way to develop and test module changes,
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.
watch task does not work with JSF portlets or fragment projects.
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.