Contact Free trial Login

Mule Maven Plugin Deployment

The Mule Maven plugin enables you to integrate the packaging, testing, and deployment of your Mule applications with your Maven lifecycle.
See Package a Mule Application for packaging instructions.

With the plugin, you can deploy your Mule application to different deployment targets, such as standalone Mule instances, clustered instances, and CloudHub.

The Mule Maven plugin is compatible with Mule runtime engine(Enterprise Edition) and with Mule Kernel (Community Edition).

Compatibility

  • Mule 4.x

  • Anypoint Studio 7.x

Mule Maven Plugin Goals

The Mule Maven plugin has three goals:

  • package
    Generates the jar file for your project. See Package Goal for details.

  • deploy
    Automatically uploads and starts your application in any of the application deployment targets (CloudHub, Runtime Fabric, or On-Premises).

  • mule:undeploy
    Automatically removes your application from any of the application deployment targets (CloudHub, Runtime Fabric, or On-Premises).

Each goal accepts parameters that are unique to the desired plugin behavior. To provide a parameter from the command line, prepend -D to the parameter name.

Deploy Goal

This goal uploads and deploys the application JAR file to any of the application deployment targets. The deploy goal binds by default to the Maven lifecycle phase: deploy.

Optional Parameters

Name Type Description

artifact

String

Path to the application JAR file to be deployed. By default is set to the application target folder.

muleDeploy

boolean

Instructs the plugin to deploy using the deployment strategy defined in the plugin configuration. If the muleDeploy parameter is not set, the plugin uploads the artifacts to the repository defined in the distributionManagement section of the application’s pom.xml file.

For example, to execute the deploy goal and set the muleDeploy parameter, you run the following command:

mvn deploy -DmuleDeploy

Undeploy Goal

This goal removes an application from any of the application deployment targets. It uses the information from the plugin configuration to remove the application from the defined deployment target.

To execute the undeploy goal, run the following command:

mvn mule:undeploy

The undeploy goal also deletes the app in Mule Maven plugin 3.3.0 and later versions.

Add the Mule Maven Plugin to a Mule Project

To add the Mule Maven plugin, you need to add its maven dependency to the project:

<plugin>
  <groupId>org.mule.tools.maven</groupId>
  <artifactId>mule-maven-plugin</artifactId>
  <version>3.3.2</version>
  <extensions>true</extensions>
</plugin>

From this repository:

<pluginRepositories>
  <pluginRepository>
    <id>mule-public</id>
    <url>https://repository.mulesoft.org/nexus/content/repositories/releases</url>
  </pluginRepository>
</pluginRepositories>

This enables the Mule Maven plugin in your project.

If <extensions>true</extensions> is not present, the plugin does not work.

Mule Application Deployment

The Mule Maven plugin allows you to automate the deployment of your Mule application to any of the application deployment targets (CloudHub, Runtime Fabric, or On-Premises).

By default, this plugin allows you to deploy using five different deployment strategies:

  • CloudHub deployment.
    Automate the deployment of your Mule Application to CloudHub.

  • Runtime Fabric deployment.
    Deploy your Mule Application to Runtime Fabric.

  • Runtime Manager REST API deployment.
    Deploy your Mule Application to your server, or server clusters using the Runtime Manager REST API.

  • Mule Agent deployment.
    Deploy your Mule Application using the Mule Agent.
    This deployment strategy only works if all your Mule instances live under the same address space.

  • Standalone runtime deployment.
    Deploy to a Mule instance running on your machine.

When deploying an application using the Mule Maven plugin you need to specify a valid deployment configuration in your pom.xml file.
You can set up a deployment configuration using their dedicated deployment references.

Deploy a Mule Application to CloudHub

Prerequisites

  • The host and port number of your HTTP Listener flow sources are properly configured.

    If you are using the HTTP Listener as sources for your flow, you need to set its host to 0.0.0.0 and its port to ${http.port}.

    CloudHub then dynamically allocates a port at deployment time.

  • All your external classes and resources are properly declared in the mule-artifact.json file of your Mule application.

    Due to Mule 4.x classloading isolation mechanism, all external classes and resources must be explicitly declared in the "exportedPackages" and "exportedResources" fields on the mule-artifact.json file before packaging and deploying the app.

    See Export Resources to learn more about working with external resources in your Mule application.

Deploying to CloudHub

  1. Make sure you added the Mule Maven plugin to your pom.xml file.

  2. Inside the plugin element, add a configuration for your CloudHub deployment, replacing the placeholder values with your CloudHub information:

    <plugin>
      <groupId>org.mule.tools.maven</groupId>
      <artifactId>mule-maven-plugin</artifactId>
      <version>3.3.2</version>
      <extensions>true</extensions>
      <configuration>
        <cloudHubDeployment>
          <uri>https://anypoint.mulesoft.com</uri>
          <muleVersion>${app.runtime}</muleVersion>
          <username>${username}</username>
          <password>${password}</password>
          <applicationName>${cloudhub.application.name}</applicationName>
          <environment>${environment}</environment>
          <properties>
            <key>value</key>
          </properties>
        </cloudHubDeployment>
      </configuration>
    </plugin>
  3. From the command line in your project’s folder, package the app and execute the deploy goal:

    mvn clean package deploy -DmuleDeploy

Redeploying to CloudHub

To redeploy the app, run the same command as you did to deploy.
CloudHub rewrites the app you had deployed.

Undeploying from CloudHub

To undeploy an app, run the following command:

mvn mule:undeploy

The undeploy command also deletes the app in Mule Maven plugin 3.3.0 and later versions.

CloudHub Deployment Reference

Parameter Description

cloudHubDeployment

Top-Level Element.

uri

Your Anypoint Platform URI.
If not set, by default this value is set to https://anypoint.mulesoft.com.

muleVersion

The Mule version that will run in your CloudHub instance.
You need to ensure that this value is equal to or higher than the minimum required Mule version of your application.

username

Your CloudHub username.

password

Your CloudHub password.

applicationName

The name of your application in CloudHub.
This name is part of the domain of your deployed app. For example, naming your application application-1 makes your app’s public domain application-1.cloudhub.io.

artifact

Absolute file location of the JAR to be deployed.
If not set, by default it is the location of the JAR generated at the package phase

environment

The CloudHub environment to which you want to deploy. This value must match any environment configured in your CloudHub account.
For Example:

<environment>Sandbox</environment>

properties

Top-Level element.
If you need to set properties for the Mule application you are deploying, you can use the <properties> top-level element:

<properties>
  <key>value</key>
</properties>

For example:

<properties>
  <http.port>8081</http.port>
</properties>

workers

The number of workers.
By default, it is set to 1.

workerType

Size of each worker.

Accepted values are:

MICRO (0.1 vCores)
SMALL (0.2 vCores)
MEDIUM (1 vCore )
LARGE (2 vCores)
XLARGE (4 vCores)
XXLARGE (8 vCores)
4XLARGE (16 vCores)

The default value is MICRO.

region

Region of worker clouds.

Accepted values are:

  • us-east-1 - US East (N. Virginia)

  • us-west-2 - US West (Oregon)

  • eu-west-1 - EU (Ireland)

  • ap-southeast-2 - Asia Pacific (Sydney)

  • ap-southeast-1 - Asia Pacific (Singapore)

  • us-west-1 - US West (N. California)

  • eu-central-1 - EU (Frankfurt)

  • ap-northeast-1 - Asia Pacific (Tokyo)

  • eu-west-2 - EU (London)

  • ca-central-1 - Canada (Central)

  • sa-east-1 - South America (São Paulo)

  • us-east-2 - US East (Ohio)

The default value is us-east-1.

businessGroup

The Business group path of the deployment.
For example:

<businessGroup>MasterOrg/SubOrg</businessGroup>

businessGroupId

The Business group id of the deployment.
This parameter is available in plugin version 3.2.7 and later.

deploymentTimeout

The allowed elapsed time, in milliseconds, between the start of the deployment process and the confirmation that the artifact has been deployed.

The default value is 1000000.

server

Maven server with Anypoint Platform credentials. This is only needed if you want to use your credentials stored in your Maven settings.xml file. This is not the Mule server name.

skip

Boolean value. When set to true, skips the plugin deployment goal. Its default value is false.

Deploy a Mule Application to Runtime Fabric

Prerequisites

Studio allows you to select only two project types when uploading an application to Exchange: example and template. To specify a different project type, publish your application using Maven.

Deploying to Runtime Fabric

  1. Make sure you added the Mule Maven plugin to your pom.xml file.

  2. Inside the plugin element, add a configuration for your Runtime Fabric deployment, replacing the placeholder values with your Runtime Fabric information:

    <plugin>
      <groupId>org.mule.tools.maven</groupId>
      <artifactId>mule-maven-plugin</artifactId>
      <version>3.3.2</version>
      <extensions>true</extensions>
      <configuration>
        <runtimeFabricDeployment>
          <uri>https://anypoint.mulesoft.com</uri>
          <muleVersion>${app.runtime}</muleVersion>
          <username>${username}</username>
          <password>${password}</password>
          <applicationName>${runtime.fabric.application.name}</applicationName>
          <environment>${environment}</environment>
          <provider>${provider}</provider>
          <properties>
            <key>value</key>
          </properties>
          <deploymentSettings>
            <publicUrl>${app.url}</publicUrl>
            <cpuReserved>500m</cpuReserved>
            <memoryReserved>800Mi</memoryReserved>
          </deploymentSettings>
        </runtimeFabricDeployment>
      </configuration>
    </plugin>
  3. From the command line in your project’s folder, package the application and execute the deploy goal:

    mvn clean package deploy -DmuleDeploy

Redeploying to Runtime Fabric

To redeploy the application, run the same command as you did to deploy.
Runtime Fabric rewrites the application you had deployed.

Runtime Fabric Deployment Reference

Parameter Description

runtimeFabricDeployment

Top-Level Element.

uri

Your Anypoint Platform URI.
If not set, by default this value is set to https://anypoint.mulesoft.com.

muleVersion

The Mule version that will run in your Runtime Fabric instance.
You need to ensure that this value is equal to or higher than the minimum required Mule version of your application.

username

Your Anypoint Platform username.

password

Your Anypoint Platform password.

applicationName

The name of your application deployed in Exchange.
This name is part of the domain of your deployed app.

target

The Runtime Fabric target name where to deploy the app.

provider

Provider type. Set to MC ("MC" specifies Runtime Fabric).

environment

The Anypoint Platform environment to which you want to deploy. This value must match any environment configured in your Anypoint Platform account.
For Example:

<environment>Sandbox</environment>

businessGroup

The Business group path of the deployment.
For example:

<businessGroup>MasterOrg/SubOrg</businessGroup>

businessGroupId

The Business group id of the deployment.
This parameter is available in plugin version 3.2.7 and later.

deploymentTimeout

The allowed elapsed time, in milliseconds, between the start of the deployment process and the confirmation that the artifact has been deployed.

The default value is 1000000.

server

Maven server with Anypoint Platform credentials. This is only needed if you want to use your credentials stored in your Maven settings.xml file. This is not the Mule server name.

properties

Top-Level element.
If you need to set properties for the Mule application you are deploying, you can use the <properties> top-level element:

<properties>
  <key>value</key>
</properties>

For example:

<properties>
  <http.port>8081</http.port>
</properties>

skip

Boolean value. When set to true, skips the plugin deployment goal. Its default value is false.

deploymentSettings

See the deploymentSettings Reference table below for a complete list of parameters that can be configured inside this element.

deploymentSettings Reference

Parameter Description

clusteringEnabled

Enable Mule clustering across each replica of the application. It requires to have at least two replicas.
By default, is set to false.
For example:

<deploymentSettings>
    <clusteringEnabled>true</clusteringEnabled>
</deploymentSettings>

replicationFactor

The number of instances for your application.
By default, it is set to 1.
For example:

<deploymentSettings>
    <replicationFactor>2</replicationFactor>
</deploymentSettings>

lastMileSecurity

Enable Last-Mile security to forward HTTPS connections to be decrypted by this application.
This requires an SSL certificate to be included in the Mule application, and also requires more CPU resources.
By default, is set to false.
For example:

<deploymentSettings>
    <lastMileSecurity>true</lastMileSecurity>
</deploymentSettings>

memoryReserved

Amount of memory to be allocated for each replica of the application. If not present, the default value is 700MB.
For example:

<deploymentSettings>
    <memoryReserved>100Mi</memoryReserved>
</deploymentSettings>

This will set 100MB of memory to each replica.

memoryMax

Amount of max memory to be allocated for each replica of the application. If a memoryReserved configuration is present, ensure that this value is equal or higher.
For example:

<deploymentSettings>
    <memoryMax>200Mi</memoryMax>
</deploymentSettings>

This will set 200MB of memory max to each replica.

cpuReserved

Amount of cores to be allocated for each replica of the application. If not present, the default value is 0.5 vCores.
For example:

<deploymentSettings>
    <cpuReserved>500m</cpuReserved>
</deploymentSettings>

This will set 0.5 vCores for each replica.

cpuMax

Amount of max cores to be allocated for each replica of the application. If a cpuReserved configuration is present, ensure that this value is equal or higher. For example:

<deploymentSettings>
    <cpuMax>1000m</cpuMax>
</deploymentSettings>

This will set a max of 1 vCores to each replica.

publicUrl

Url of the deployed application. For example:

<deploymentSettings>
    <publicUrl>myapp.anypoint.com</publicUrl>
</deploymentSettings>

Deploy a Mule Application to a Standalone Mule Runtime Engine

  1. Make sure you added the Mule Maven plugin to your pom.xml file.

  2. Inside the plugin element, add a configuration for your standalone deployment, replacing the placeholder values with your local Mule runtime engine information:

    <plugin>
      <groupId>org.mule.tools.maven</groupId>
      <artifactId>mule-maven-plugin</artifactId>
      <version>3.3.2</version>
      <extensions>true</extensions>
      <configuration>
        <standaloneDeployment>
          <muleHome>${mule.home.test}</muleHome>
          <muleVersion>${app.runtime}</muleVersion>
        </standaloneDeployment>
      </configuration>
    </plugin>
  3. From the command line in your project’s folder, package the application and execute the deploy goal:

    mvn clean package deploy -DmuleDeploy

Standalone Deployment Reference

Parameter Description

standaloneDeployment

Top-Level Element.

muleVersion

The Mule version running in your local machine instance.
If this value does not match the Mule version running in your deployment target, the plugin raises an exception.

The Mule Maven Plugin does not download a Mule runtime engine if these values don’t match.

muleHome

The location of the Mule instance in your local machine.

deploymentTimeout

The allowed elapsed time, in milliseconds, between the start of the deployment process and the confirmation that the artifact has been deployed.

The default value is 1000000.

skip

Boolean value. When set to true, skips the plugin deployment goal. Its default value is false.

Deploy a Mule Application Using the Runtime Manager REST API

Prerequisites

Deploying Using the Runtime Manager REST API

  1. Make sure you added the Mule Maven plugin to your pom.xml file.

  2. Inside the plugin element, add a configuration for your Runtime Manager deployment, replacing the placeholder values with your Runtime Manager information:

    <plugin>
      <groupId>org.mule.tools.maven</groupId>
      <artifactId>mule-maven-plugin</artifactId>
      <version>3.3.2</version>
      <extensions>true</extensions>
      <configuration>
        <armDeployment>
          <muleVersion>${app.runtime}</muleVersion>
          <uri>https://anypoint.mulesoft.com</uri>
          <target>${target}</target>
          <targetType>${target.type}</targetType>
          <username>${username}</username>
          <password>${password}</password>
          <environment>${environment}</environment>
          <properties>
            <key>value</key>
          </properties>
        </armDeployment>
      </configuration>
    </plugin>
  3. From the command line in your project’s folder, package the application and execute the deploy goal:

    mvn clean package deploy -DmuleDeploy

Runtime Manager REST API Deployment Reference

Parameter Description

armDeployment

Top-Level Element.

muleVersion

The Mule version required for your application to run in your deployment target.
If this value does not match the Mule version running in your deployment target, the plugin raises an exception.

The Mule Maven Plugin does not download a Mule runtime engine if these values don’t match.

uri

The server URI where your Mule instances are installed.

If not set, by default this value is set to https://anypoint.mulesoft.com.

target

The server name for the server where your Mule instances are installed.

targetType

The type of target to which you are deploying.

Valid values are:

  • server

  • serverGroup

  • cluster

username

Your username for the server where your Mule instances are installed.

password

Your password for the server where your Mule instances are installed.

environment

The environment name for the server where your Mule instances are installed. This value must match any environment configured in your Runtime Manager account.
For Example:

<environment>Sandbox</environment>

businessGroup

The Business group path of the deployment.
For example:

<businessGroup>MasterOrg/SubOrg</businessGroup>

businessGroupId

The Business group id of the deployment.
This parameter is available in plugin version 3.2.7 and later.

deploymentTimeout

The allowed elapsed time, in milliseconds, between the start of the deployment process and the confirmation that the artifact has been deployed.

The default value is 1000000.

server

Maven server with Anypoint Platform credentials. This is only needed if you want to use your credentials stored in your Maven settings.xml file. This is not the Mule server name.

properties

Top-Level element.
If you need to set properties for the Mule application you are deploying, you can use the <properties> top-level element:

<properties>
  <key>value</key>
</properties>

For example:

<properties>
  <http.port>8081</http.port>
</properties>

skip

Boolean value. When set to true, skips the plugin deployment goal. Its default value is false.

Deploy a Mule Application Using the Mule Agent

  1. Make sure you added the Mule Maven plugin to your pom.xml file.

  2. Inside the plugin element, add a configuration for your Mule Agent deployment, replacing the URI value with your remote server information:

    <plugin>
      <groupId>org.mule.tools.maven</groupId>
      <artifactId>mule-maven-plugin</artifactId>
      <version>3.3.2</version>
      <extensions>true</extensions>
      <configuration>
        <agentDeployment>
          <uri>http://localhost:9999/</uri>
        </agentDeployment>
      </configuration>
    </plugin>
  3. From the command line in your project’s folder, package the application and execute the deploy goal:

    mvn clean package deploy -DmuleDeploy

Mule Agent Deployment Reference

Parameter Description

agentDeployment

Top-Level Element.

muleVersion

The Mule version required for your application to run in your deployment target.
If this value does not match the Mule version running in your deployment target, the plugin raises an exception.

The Mule Maven Plugin does not download a Mule runtime engine if these values don’t match.

uri

The server URI where your Mule instances are installed.

deploymentTimeout

The allowed elapsed time, in milliseconds, between the start of the deployment process and the confirmation that the artifact has been deployed.

The default value is 1000000.

skip

Boolean value. When set to true, skips the plugin deployment goal. Its default value is false.

Deploy a Domain

The Mule Maven plugin supports deploying domains only when using the standalone deployment strategy, or the Mule agent deployment strategy.

To deploy a domain, use the same configuration and deployment steps you use when deploying an application. For example, to deploy a domain to a standalone instance:

  1. Add the Mule Maven plugin to your pom.xml file.

  2. Inside the plugin element, add a configuration for your standalone deployment, replacing the placeholder values with your local Mule runtime engine information:

    <plugin>
      <groupId>org.mule.tools.maven</groupId>
      <artifactId>mule-maven-plugin</artifactId>
      <version>3.3.2</version>
      <extensions>true</extensions>
      <configuration>
        <standaloneDeployment>
          <muleHome>${mule.home.test}</muleHome>
          <muleVersion>${app.runtime}</muleVersion>
        </standaloneDeployment>
      </configuration>
    </plugin>
  3. From the command line in your project’s folder, package the domain and execute the deploy goal:

    mvn clean package deploy -DmuleDeploy

Encrypt Credentials

Encrypted credentials are available in all platform deployments: CloudHub, Runtime Fabric, and Runtime Manager. To use encrypted credentials when deploying, you need to set up your Maven master encrypted password and your settings-security.xml file.

  1. Create a master password for your Maven configuration.

    mvn --encrypt-master-password <yourMasterPassword>

    Maven returns your master password encrypted:

    {l9vZ2uM5SdgHy+H12z4pX7LEOZn3Kbnqmt3kIquLjnQ=}
  2. Create a settings-security.xml file in your ~/.m2 repository and add your encrypted master password.

    <settingsSecurity>
      <master>{l9vZ2uM5SdgHy+H12z4pX7LEOZn3Kbnqmt3kIquLjnQ=}</master>
    </settingsSecurity>
  3. Encrypt your Anypoint platform password:

    mvn --encrypt-password <yourAnypointPlatformPassword>

    Maven returns your Anypoint platform password encrypted:

    {HTWFGH5BG9QmvJ1B=}
  4. Add your encrypted Anypoint Platform password to your settings.xml file in the <server> section:

    <settings>
     ...
      <servers>
       ...
        <server>
          <id>my.anypoint.credentials</id>
          <username>my.anypoint.username</username>
          <password>{HTWFGH5BG9QmvJ1B=}</password>
        </server>
       ...
      </servers>
     ...
    </settings>
  5. In your configuration deployment, reference the credentials injecting the server id configured in your settings.xml file. Below is an example of a CloudHub Deployment using encrypted credentials:

<plugin>
  <groupId>org.mule.tools.maven</groupId>
  <artifactId>mule-maven-plugin</artifactId>
  <version>3.3.2</version>
  <extensions>true</extensions>
  <configuration>
      <cloudHubDeployment>
          <uri>https://anypoint.mulesoft.com</uri>
          <muleVersion>${app.runtime}</muleVersion>
          <server>my.anypoint.credentials</server>
          <applicationName>${cloudhub.application.name}</applicationName>
          <environment>${environment}</environment>
          <properties>
              <key>value</key>
          </properties>
      </cloudHubDeployment>
  </configuration>
</plugin>
Make sure that the username and password are not set in the deployment configuration, or they will overwrite the defined server ID.

Skip Plugin Execution

You can skip the plugin execution by setting the skip parameter to true inside your deployment configuration:

<plugin>
  <groupId>org.mule.tools.maven</groupId>
  <artifactId>mule-maven-plugin</artifactId>
  <version>3.3.2</version>
  <extensions>true</extensions>
  <configuration>
    <standaloneDeployment>
      <muleHome>${mule.home.test}</muleHome>
      <skip>true</skip>
    </standaloneDeployment>
  </configuration>
</plugin>

Skip Deployment Verification

You can skip the status verification of your deployed app by setting the skipDeploymentVerification parameter to true inside of any of the platform deployments (Cloudhub, Runtime Manager, and Runtime Fabric):

<plugin>
  <groupId>org.mule.tools.maven</groupId>
  <artifactId>mule-maven-plugin</artifactId>
  <version>3.3.2</version>
  <extensions>true</extensions>
  <configuration>
    <runtimeFabricDeployment>
      ...
      <skipDeploymentVerification>true</skipDeploymentVerification>
      ...
    </runtimeFabricDeployment>
  </configuration>
</plugin>

If the skipDeploymentVerification parameter is not present, the default value is false.
This feature is available in plugin version 3.2.5 and later.

Anypoint Runtime Manager On-Premises TLS Errors

When trying to connect to an instance of Runtime Manager that’s on an Anypoint Platform Private Cloud Edition installation, the plugin validates certificates for that server. If you haven’t installed the server certificates in your truststore, an SSL error occurs. To avoid this problem, you can run the plugin in an insecure mode, which skips the security validations. You can use the armInsecure tag or the arm.insecure system property.

Enabling an insecure connection is a dangerous practice. Don’t use this unless you know what you are doing and your On-Premises installation is isolated in a local network.

See the configuration example below:

<plugin>
  <groupId>org.mule.tools.maven</groupId>
  <artifactId>mule-maven-plugin</artifactId>
  <version>3.3.2</version>
  <extensions>true</extensions>
  <configuration>
    <armDeployment>
        <target>${target}</target>
        <targetType>${target.type}</targetType>
        <username>${username}</username>
        <password>${password}</password>
        <environment>${environment}</environment>
        <armInsecure>true</armInsecure>
    </armDeployment>
  </configuration>
</plugin>

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.