Liferay Development with Blade CLI

   

Liferay Blade CLI Commands

Overview


Blade CLI is a command line tool, which provides developers with the possibility to initialize a Liferay workspace project, create Liferay modules, start/stop the application server, and perform code upgrade operations. This article shows how to speed up the environment configuration and development process by leveraging the various Blade CLI commands.


Blade CLI Commands


Check version


dev@liferay:~/Work/Projects/liferay$ blade version

blade version 4.0.9.202107011607


If Blade CLI is not installed yet - it can be installed with these instructions.

To update Blade CLI to the latest version - run command:


dev@liferay:~/Work/Projects/liferay$ blade update


Workspace Initialization


Liferay workspace can be initialized with the blade init command.

To get the list of available products run:


dev@liferay:~/Work/Projects/liferay$ blade init -l

dxp-7.4-ga1

dxp-7.3-sp1

dxp-7.2-sp5

dxp-7.1-sp6

dxp-7.0-sp17

portal-7.4-ga4

portal-7.3-ga8

portal-7.2-ga2

portal-7.1-ga4

portal-7.0-ga7

commerce-2.0.7-7.2

commerce-2.0.7-7.1



Then, use the required product in blade init command:


dev@liferay:~/Work/Projects/liferay$ blade init -v portal-7.4-ga4


Note: simplified version can be also used blade init -v 7.4


This will generate a Gradle Liferay Workspace by default.

To generate Maven Liferay Workspace use the following command:


dev@liferay:~/Work/Projects/liferay$ blade init -v 7.4 -b maven


Running gw (gradle wrapper) tasks


Check available tasks with blade gw tasks command:

Blade CLI gw Tasks


To initialize the Liferay bundle run:

dev@liferay:~/Work/Projects/liferay$ blade gw initBundle


For modules deployment run:

dev@liferay:~/Work/Projects/liferay$ blade gw deploy

Server management


Start server:

dev@liferay:~/Work/Projects/liferay$ blade server start

To view the log execute 'tail -f ~/Work/Projects/liferay/bundles/tomcat-9.0.43/logs/catalina.out'


Stop server:

dev@liferay:~/Work/Projects/liferay$ blade server stop


Running Gogo Shell Commands


With blade sh we can run the Gogo shell commands directly, sample:


dev@liferay:~/Work/Projects/liferay$ blade sh lb kaleo

lb kaleo

START LEVEL 20

   ID|State      |Level|Name

  790|Active     |   10|Liferay Portal Workflow Kaleo Definition Implementation (6.0.1)|6.0.1

  791|Active     |   10|Liferay Portal Workflow Kaleo Runtime Form Implementation (4.0.0)|4.0.0

  792|Active     |   10|Liferay Portal Workflow Kaleo Runtime Implementation (6.0.4)|6.0.4


Modules Creation


To check which modules can be generated with Blade CLI - run command:


dev@liferay:~/Work/Projects/liferay$ blade create -l

Blade CLI Module Types

For example, we can create an MVCPortlet module using the command:

 

dev@liferay:~/Work/Projects/liferay$ blade create -t mvc-portlet -p com.lifedev.mvcportlet -c LifeDevPortlet lifedev-portlet


(t - module type, p - package, c - classname)


Once created - module can be deployed with Blade CLI:


dev@liferay:~/Work/Projects/liferay$ blade gw deploy


and then checked with Gogo Shell:


dev@liferay:~/Work/Projects/liferay$ blade sh lb com.lifedev

lb com.lifedev

START LEVEL 20

   ID|State      |Level|Name

 1388|Active     |   15|lifedev-portlet (1.0.0)|1.0.0



Enjoy 😏

Comments

Popular posts from this blog

Liferay Search Container Example

Installing Blade CLI from Command Line

Liferay Keycloak integration