Deploying a project to Liferay DXP can be completed using your tool of choice. The following tools are preconfigured (or can be easily configured) for Liferay project generation:
The deployment process is the same across all tools; the deployment command/action builds and 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. The Liferay Home folder is preconfigured in most cases; if it’s not, ways to configure it are included below. All tools support JAR and WAR-style project deployment.
It’s recommended to deploy Liferay projects within a Liferay Workspace. Most tools, however, support deploying projects in a standalone environment (except for IntelliJ). Visit the appropriate section to learn how to deploy a project with the highlighted tool.
Blade CLI
This is the recommended way to deploy Gradle and Maven projects in a Liferay Workspace via command line. Blade CLI is leveraged by Dev Studio and IntelliJ too.
Run this command to deploy your project:
blade deploy
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:
blade deploy -l
Gradle
Deploying with pure Gradle is not recommended unless you prefer to develop outside of a Liferay Workspace. Blade CLI is a better tool for deploying Liferay Gradle projects in most cases.
-
Apply the Liferay Gradle plugin in your project’s
build.gradle
file:apply plugin: "com.liferay.plugin"
-
Extend the Liferay extension object to set your Liferay Home and
deploy
folder:liferay { liferayHome = "../../../../liferay-ce-portal-7.1.1-ga2" deployDir = file("${liferayHome}/deploy") }
-
Run this command to deploy your project:
./gradlew deploy
Liferay Dev Studio
These steps assume you’ve installed a Liferay server in Dev Studio.
-
Right-click the server from the Servers window and select Add and Remove….
-
Add the project(s) you’d like to deploy from the Available window to the Configured window. Then click Finish.
-
Verify your project builds, deploys, and starts successfully by viewing the results in the Console window.
Dev Studio’s deployment mechanism executes the watch
task behind the scenes.
For more information on what to expect from the watch
task, see
this article.
Liferay IntelliJ Plugin
These steps assume you’ve installed a Liferay server in IntelliJ. A configured Liferay Workspace is required to create and deploy Liferay projects in IntelliJ.
-
Right-click your project from within the Liferay Workspace folder structure and select Liferay → Deploy.
This automatically loads a build progress window viewable at the bottom of your IntelliJ instance.
-
Verify that your project builds successfully from the build progress window. Then navigate back to your server’s window and confirm it starts in your configured Liferay DXP instance.
Maven
If you’re developing your project in a Liferay Workspace, skip to step 3.
-
Add the following plugin configuration to your Liferay Maven project’s parent
pom.xml
file.<build> <plugins> <plugin> <groupId>com.liferay</groupId> <artifactId>com.liferay.portal.tools.bundle.support</artifactId> <version>3.4.1</version> <executions> <execution> <id>deploy</id> <goals> <goal>deploy</goal> </goals> <phase>pre-integration-test</phase> </execution> </executions> </plugin> </plugins> </build>
This POM configuration applies Liferay’s Bundle Support plugin. This plugin is applied in Liferay Workspace by default. The Bundle Support configuration defines the executions tag, which configures the Bundle Support plugin to run during the
pre-integration-test
phase of your Maven project’s build lifecycle. Thedeploy
goal is defined for that lifecycle phase. -
Define your Liferay home folder in your POM. You can do this by adding the following logic within the
plugin
tags, but outside of theexecution
tags:<configuration> <liferayHome>C:/liferay/liferay-ce-portal-7.1-ga1</liferayHome> </configuration>
-
Run this command to deploy your project:
mvn verify