Blade CLI: Your Secret Weapon for Effortless Liferay Development

Liferay Version: 7.4

Welcome, Liferay developers! Are you ready to take your development experience to the next level? Look no further than Blade CLI, a powerful command-line tool designed to streamline your Liferay project workflow. This comprehensive guide will equip you with the knowledge to install Blade CLI, create a workspace for your project, and deploy modules with ease.

What is Blade CLI?

Imagine a Swiss Army knife for Liferay development. That’s essentially what Blade CLI is. It’s a versatile command-line tool that empowers you to:

  • Effortlessly create Liferay workspaces: Establish a structured environment for your project, complete with essential configurations.
  • Simplify project management: Manage various Liferay projects efficiently from the command line.
  • Deploy modules with a breeze: Leverage Blade’s commands to build, deploy, and clean your Liferay modules with minimal effort.

Getting Started with Blade CLI

Before diving into the world of workspaces and deployments, let’s ensure you have Blade CLI installed.

npm install -g @liferay/cli

Creating a Liferay Workspace: Your Project’s Foundation

A Liferay workspace acts as the foundation for your development endeavors. It provides a structured directory layout, pre-configured settings, and essential tools to streamline your workflow. Here’s how to create a workspace using Blade CLI:

  1. Craft Your Project Folder: Open your terminal and navigate to your desired project location using the cd command. Then, create a new folder for your project using
    mkdir my-liferay-project
    cd my-liferay-project
  2. Initialize Your Workspace with Blade: Now, it’s time to leverage Blade CLI to create your workspace. Use the blade init command, specifying the Liferay version (DXP or Portal) you’ll be targeting:
    blade init -v <dxp/portal version>
    Replace <dxp/portal version> with the appropriate version (e.g., dxp-7.4.x for Liferay DXP or portal-7.4-ga102 for Liferay Portal). Blade will take care of generating the workspace structure with essential configurations, saving you valuable time.
  3. (Optional) Bundle Initialization and Workspace Configuration:
    • Bundle Initialization (Optional): For specific development scenarios, you might require a bundle. You can initialize a bundle using blade server init. Refer to the Liferay documentation for detailed use cases of bundle initialization.
    • Workspace Configuration: Locate the gradle.properties file within your newly created workspace. Edit this file and add the following line, replacing <Tomcat parent folder> with the actual path to your Tomcat’s parent directory (without quotes): liferay.workspace.home.dir = <Tomcat parent folder> This configuration helps Blade interact with your local Tomcat instance during deployments.

Seamlessly Integrate Your Favorite Code Editor

Blade CLI understands the importance of developer comfort. It allows you to launch your preferred code editor directly from the terminal within your project directory. Here’s how to access some popular editors:

  • Visual Studio Code: code .
  • Sublime Text: osub
  • Vim: vi

Building Your Client-Extension Structure

For projects involving React elements or SpringBoot, you’ll need a proper client-extension folder structure. Blade CLI offers two approaches to achieve this:

  1. Utilizing Sample Workspace (Recommended for Beginners): Use the blade samples client-extensions command. This will download a sample workspace containing various pre-configured client extension folders. Keep the folders you need and rename them accordingly. This is a great way to get started quickly with a basic structure.
  2. Manual Creation (For Experienced Developers): If you prefer more control over your project structure, you can manually create the necessary folders and files within your project directory. Refer to the Liferay documentation for client-extension folder structure specifics.

Deployment Made Easy: Leverage Blade CLI Commands

Now comes the exciting part: deploying your Liferay modules! Navigate to the directory containing your specific module. Blade CLI offers a robust set of commands to streamline deployment:

  • Build (blade gw build): Prepares your module for deployment by generating the necessary artifacts.
  • Deploy (blade gw deploy): The recommended approach. This powerful command combines build and deploy functionalities in one step, simplifying the process.
  • Clean (blade gw clean): Removes generated module artifacts like JAR or CX zip files, useful for cleaning up after deployments or when you want to rebuild your module from scratch.
  • Rest Builder Modules (blade gw buildRest): Specifically used for deploying modules created with the Liferay Service Builder.
  • Service Builder Modules (blade gw buildService): Exclusively for deploying modules built using the Liferay Service Builder tool.

Conclusion: Embrace Efficiency with Blade CLI

By incorporating Blade CLI into your Liferay development workflow, you’ll experience a significant boost in efficiency. From workspace creation to effortless deployments, Blade streamlines the process, allowing you to focus on what truly matters: crafting exceptional Liferay applications.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

close
Thanks !

Thanks for sharing this, you are awesome !