DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Create Proxy Application for Mule APIs
  • Maven Dependency Scope Applied
  • A Maven Story
  • Create Custom DataWeave Functions in Mule 4

Trending

  • The Agentic Agile Office: Streamlining Enterprise Agile With Autonomous AI Agents
  • Offline-First Patch Management for 10,000 Edge Nodes: A Practical Architecture That Scales
  • How to Format Articles for DZone
  • A Hands-On ABAP RESTful Programming Model Guide
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Mule Maven Plugin for Deploying MuleSoft Applications

Mule Maven Plugin for Deploying MuleSoft Applications

In this article take a look at Mule Maven Plugin for deploying MuleSoft applications.

By 
Jitendra Bafna user avatar
Jitendra Bafna
·
Updated Jan. 23, 20 · Tutorial
Likes (8)
Comment
Save
Tweet
Share
36.6K Views

Join the DZone community and get the full member experience.

Join For Free

What Is Mule Maven Plugin?

Mule Maven Plugin allows you to deploy and undeploy a MuleSoft application. It is compatible with the Enterprise Mule Runtime engine and Community Mule Kernel.

Mule Maven Plugin is capable of deploying applications automatically to on-premise, CloudHub, and Anypoint Runtime Fabric Manager.

Mule Maven plugin supports three goals:

  • Package: Generates jar or executable files for your Mule application.

    • mvn package
  • Deploy: It automatically uploads, deploys and starts the application on the target system (on-premise, CloudHub, Anypoint Runtime Fabric).

    • mvn deploy -DmuleDeploy
  • Undeploy: It automatically removes the application from the target system (on-premise, CloudHub, Anypoint Runtime Fabric).

    • mvn mule:undeploy
You may also like:  Deploy Mule 4 Application To Anypoint Runtime Fabric Using Maven Plugin

You can find Mule Maven Plugin in POM.xml by default whenever you create a Mule application, otherwise, you can define the plugin in POM.xml as shown below:

XML
 




x


 
1
<plugin>
2
<groupId>org.mule.tools.maven</groupId>
3
<artifactId>mule-maven-plugin</artifactId>
4
<version>3.3.5</version>
5
</plugin>



Deploying a Mulesoft Application to Anypoint CloudHub Using Mule Maven Plugin

Mule Maven Plugin has the capability of deploying applications to Anypoint CloudHub. We need to understand some of the Mule Maven Plugin parameters required for deploying applications to CloudHub. Learn how to deploy a mule application in Cloudhub.

Parameter

Description

uri

Your Anypoint Platform URI.

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

muleVersion

The Mule runtime engine version that will run in your CloudHub instance.

applicationName

The name of your application in CloudHub.

username

Your Cloudhub username.

password

Your Cloudhub password.

server

Maven server with Anypoint Platform credentials.

workers

The number of workers.

By default, it is set to 1

workerType

Size of each worker.

The default value is MICRO.

environment

The CloudHub environment to which you want to deploy.

businessGroup


properties

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.url>http://abc.com/employees</http.url>

</properties>

region

Region of workers cloud.

The default value is us-east-1.


Worker Size

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

Worker Region

  • us-east-1 (default; US East, N. Virginia)
  • us-east-2 (US East, Ohio)
  • us-west-1 (US West, N. California)
  • us-west-2 (US West, Oregon)
  • eu-central-1 (EU, Frankfurt)
  • eu-west-1 (EU, Ireland)
  • eu-west-2 (EU, London)
  • ap-southeast-1 (Asia Pacific, Singapore)
  • ap-southeast-2 (Asia Pacific, Sydney)
  • ap-northeast-1 (Asia Pacific, Tokyo)
  • ca-central-1 (Canada, Central)
  • sa-east-1 (South America, São Paulo)

For deploying applications to CloudHub using Mule Maven Plugin, you need a configuration in POM.xml as shown below:

XML
 




x
17


 
1
<plugin>
2
   <groupId>org.mule.tools.maven</groupId>
3
   <artifactId>mule-maven-plugin</artifactId>
4
   <version>3.3.5</version>
5
   <extensions>true</extensions>
6
   <configuration>
7
      <cloudHubDeployment>
8
         <username>Anypoint Username</username>
9
         <p>Anypoint Password</password>         
10
         <workers>1</workers>
11
         <workerType>Micro</workerType>
12
         <environment>Sandbox</environment>
13
         <muleVersion>4.2.2</muleVersion>
14
         <applicationName>Demo-Application</applicationName>
15
      </cloudHubDeployment>
16
   </configuration>
17
</plugin>



Related tutorial: How to Publish Maven Artifacts to Nexus OSS

To deploy applications to CloudHub, you need to execute the below command:

 mvn package deploy -DmuleDeploy  

Currently, in the above configuration, we have hard coded all the values for the parameter. Instead of passing hard coded values, we can define properties for each parameter and pass properties values through a maven command as shown below:     


XML
 




xxxxxxxxxx
1
17


 
1
<plugin>
2
   <groupId>org.mule.tools.maven</groupId>
3
   <artifactId>mule-maven-plugin</artifactId>
4
   <version>3.3.5</version>
5
   <extensions>true</extensions>
6
   <configuration>
7
      <cloudHubDeployment>
8
         <username>${username}</username>
9
         <p>${password}</password>         
10
         <workers>${workers}</workers>
11
         <workerType>${worker.type}</workerType>
12
         <environment>${environment}</environment>
13
         <muleVersion>${mule.version}</muleVersion>
14
         <applicationName>${application.name}</applicationName>
15
      </cloudHubDeployment>
16
   </configuration>
17
</plugin>


To deploy an application to CloudHub, you need to execute the below command:

 mvn package deploy -DmuleDeploy -Dusername=AnypointUsername -Dpassword=AnypointPassword -Dworkers=1 -Dworker.type=Micro -Denvironment=Sandbox -Dmule.version=4.2.2 

You can see some issues that we are passing password in cleartext, and it is not recommended to store your password in cleartext. Please go through the below video; it will explain how to encrypt your Anypoint Platform password in POM with Maven to deploy an application into CloudHub.



Also, please watch the video below titled, “Deploying Mulesoft Application to Cloudhub using Mule Maven Plugin”


Deploying Mulesoft Application to On-Premises (Standalone) Using Mule Maven Plugin

Mule Maven Plugin has the capability of deploying applications to on-premise MuleSoft runtime. We need to understand some Mule Maven Plugin parameters required for deploying application to MuleSoft runtime.

Parameter

Description

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.

muleHome

The location of the Mule instance in your local machine.


For deploying applications to on-premises, you need to do below configuration in POM.xml.

XML
 




x
12


 
1
<plugin>
2
   <groupId>org.mule.tools.maven</groupId>
3
   <artifactId>mule-maven-plugin</artifactId>
4
   <version>3.3.5</version>
5
   <extensions>true</extensions>
6
   <configuration>
7
      <standaloneDeployment>
8
         <muleVersion>${mule.version}</muleVersion>
9
         <muleHome>${mule.home}</muleHome>        
10
      </standaloneDeployment>
11
   </configuration>
12
</plugin>



To deploy Application to on-premise, you need to execute the below command:

 mvn package deploy -DmuleDeploy -Dmule.version=4.2.2 -Dmule.home=/mule/bin  

Conclusion

Mule Maven Plugin is capable of deploying a MuleSoft application into CloudHub, Anypoint Runtime Fabric, Standalone, Server Group, and MuleSoft Cluster.

This is how you can make use of Mule Maven Plugin for deploying applications to CloudHub and on-premise (standalone).

Further Reading

Mule Maven Plugin for CloudHub Deployment

Set Up Anypoint Studio: All You Need to Know

application Apache Maven MuleSoft

Opinions expressed by DZone contributors are their own.

Related

  • Create Proxy Application for Mule APIs
  • Maven Dependency Scope Applied
  • A Maven Story
  • Create Custom DataWeave Functions in Mule 4

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook