Creating a Blade Profile

There are two steps to follow when adding a new Blade profile:

You’ll learn how to create a profile first.

Creating a New Profile

To create a new Blade profile, follow these steps:

  1. Create a generic OSGi module.

  2. To create a new command, create the command and arguments classes extending BaseCommand and BaseArgs, respectively, as described in the Creating Custom Commands article. These classes should reside in the profile module’s src/main/java/PACKAGE_NAME folder. These classes register your command and arguments to Blade CLI.

  3. To override a default command, follow the same steps outlined here:

    • Create a command class
    • Create an arguments class
    • Define your commands’ fully qualified class names for the service loader

    Instead of extending the BaseCommand and BaseArgs, classes, however, extend the command/arguments classes defined for the command you intend to override. Make sure to also set the @Parameters annotation’s commandNames argument to the command to override.

    For example, if you intend to override the default deploy command, your arguments class declaration would look like this:

    @Parameters(commandDescription = "Overridden Deploy Command", commandNames = "deploy")
    public class OverriddenArgs extends DeployArgs {

    The corresponding command class override would look like this:

    public class OverriddenCommand extends BaseCommand<OverriddenArgs> {
        public void execute() throws Exception {
    	        OverriddenArgs args = getArgs();
            getBladeCLI().out("OverriddenCommand says " + args.isWatch());
        public Class<OverriddenArgs> getArgsClass() {
            return OverriddenArgs.class;

    You can search for the default command/arguments classes here.

  4. To associate a command to your new profile, set the BladeProfile annotation in your command class:

    public class NewCommand extends BaseCommand<NewArgs> {

    The annotation’s parameter should specify the profile you want to associate the command with (e.g., myprofile).

Excellent! You’ve created a new Blade profile and learned how to add new commands or override default commands by leveraging the profile.

You can reference the sample profile project to examine a new command and overridden command’s setup in a custom profile.

Next, you’ll learn how to set your new profile for use in a Liferay Workspace.

Setting a Profile

To set your new Blade profile in a Liferay Workspace, open the ${workspaceDir}/ file and set the property to your profile name:

This specifies which Blade profile is active and uses its defined commands. The default setting is gradle. You can also set this property to maven out-of-the-box, which is applied for Maven-based workspaces. You can only set one profile for a workspace.

You can specify the Blade profile for a workspace when initializing it too. This is done by passing the profile name as an argument when creating the workspace:

blade init -P [profile-name] [workspace-name]

For example, if you execute the following command:

blade init -P myprofile my-new-custom-workspace

Your my-new-custom-workspace has the following properties set in its ${workspaceDir}/ file:


Awesome! You’ve set your new Blade profile!

« Installing New Extensions for Blade CLICommon Errors with Blade CLI »