Mastering Liferay Workspaces and Tooling

Course Overview

Initializing Clarity's Local Developer Environment

Liferay Blade includes several essential commands for initializing and managing your local Liferay server environment. In these exercises, you’ll learn how to use these commands: blade init, blade server init, blade server start, blade server stop, and blade server restart.

Exercise: Initializing a Workspace

As explained in the previous module, blade init initializes a new Liferay workspace. A workspace is a structured environment for developing Liferay code projects such as modules, themes, and client extensions. Here you’ll initiate a workspace:

  1. Open a new terminal window.
  2. Navigate to the location where you want to create your workspace.
  3. Run this command:

    blade init clarity-liferay-workspace
    This should return a list of available Liferay releases.
  4. Enter the number for the version you want to target.
  5. Verify a new folder called clarity-liferay-workspace appears.
    This is the workspace’s root folder, known as LIFERAY_WORKSPACE_HOME.

With the workspace in place, you can initialize the local bundle.

Exercise: Initializing a Local Liferay Bundle

The blade server init command initializes a local Liferay server in your workspace. This is the fastest way to do local development, as it eliminates dependencies on remote server availability and eliminates the risk of collisions with your teammates during active development cycles. Here, you’ll initialize the local Liferay bundle.

  1. Navigate into the new workspace:

    cd clarity-liferay-workspace
    
  2. Run this command:

    blade server init
    If this is your first time initializing this version of Liferay, this begins downloading the bundle. Subsequent initializations for this version use the local cached version.
  3. Verify the build was successful:

    blade server init
    Downloading https://services.gradle.org/distributions/gradle-8.5-bin.zip
    ............10%.............20%............30%.............40%.............50%............60%.............70%.............80%............90%.............100%
    Welcome to Gradle 8.5!
    Here are the highlights of this release:
     - Support for running on Java 21
     - Faster first use with Kotlin DSL
     - Improved error and warning messages
    For more details see https://docs.gradle.org/8.5/release-notes.html
    Starting a Gradle Daemon (subsequent builds will be faster)
    > Task :downloadBundle
    Download https://releases-cdn.liferay.com/dxp/2024.q3.3/liferay-dxp-tomcat-2024.q3.3-1727686939.7z
    Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
    You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
    For more on this, please refer to https://docs.gradle.org/8.5/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
    BUILD SUCCESSFUL in 1m 37s
    4 actionable tasks: 4 executed
  4. Verify a new bundles folder appears in the workspace’s root folder.
  5. Navigate into the bundles folder:

    cd bundles
    This folder is equivalent of your LIFERAY_HOME.
  6. List the contents of this directory by executing one of the following commands.

    For Mac/Linux:

    ls -all
    

    For Windows:

    dir
    Take note of the folder’s contents.
  7. Return to the workspace’s root folder:

    cd ..

Some blade commands only execute correctly if you're in the workspace’s root folder. If you get an error, double check that you are in the correct location.

With the bundle initialized, you can start up the local Liferay server.

Exercise: Managing the Local Liferay Server

The blade server start command starts the local Liferay server in your workspace, while the blade server stop command stops the server. Here, you’ll start and stop the server.

  1. Ensure you’re in your workspace’s root folder.
  2. Run this command:

    blade server start
  3. Go to localhost:8080 and verify the server started successfully. This process may take a few minutes.
  4. Run this command:

    blade server stop
  5. Wait for confirmation that the server has stopped.
  6. Refresh the browser page to verify the server has stopped.

Conclusion

Great! You’ve initialized a local Liferay bundle that Clarity’s team can use for development. Next you’ll configure this environment.

Loading Knowledge

Capabilities

Product

Education

Contact Us

Connect

Powered by Liferay
© 2024 Liferay Inc. All Rights Reserved • Privacy Policy