<profiles>
...
<profile>
<id>mule-extra-repos</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>mule-public</id>
<url> https://repository.mulesoft.org/nexus/content/repositories/public </url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>mule-public</id>
<url> https://repository.mulesoft.org/nexus/content/repositories/public </url>
</pluginRepository>
</pluginRepositories>
</profile>
...
</profiles>
Maven Tools for Mule
Mule runtime engine version 3.8 reached its End of Life on November 16, 2021. For more information, contact your Customer Success Manager to determine how to migrate to the latest Mule version. |
Maven Tools for Mule is a plugin for Maven that allows you to develop Mule applications using Maven tooling. The kit provided by the plugin includes archetypes for building regular Mule applications, Mule domains, and Mule domain bundles.
Assumptions
This document assumes that you are familiar with Maven, managing pom.xml files, and working with Maven plugins. (If you are just getting started with Maven, we suggest you follow Maven’s Getting Started tutorial.) Additionally, this document assumes familiarity with developing Mule applications within Maven. For more information about Mule and Maven, see Using Maven with Mule.
Adding the Plugin to Maven
Adding the Maven Dependency for the Plugin
For the plugin to work, you need to add some entries in your settings.xml
file, as shown below.
-
Edit
settings.xml
to add a new profile with the followingrepositories
andpluginRepositories
. -
Add a new
pluginGroup
, as shown below.<pluginGroups> ... <pluginGroup>org.mule.tools</pluginGroup> ... </pluginGroups>
Creating a Mule Application
Maven Tools for Mule makes it extremely easy to create a Mule application, by running Maven with a few simple parameters, as shown below.
mvn archetype:generate -DarchetypeGroupId=org.mule.tools.maven -DarchetypeArtifactId=maven-achetype-mule-app -DarchetypeVersion=1.0 -DgroupId=org.mycompany.app -DartifactId=mule-app -Dversion=1.0-SNAPSHOT -DmuleVersion=3.8.0 -Dpackage=org.mycompany.app -Dtransports=http,jms,vm,file,ftp -Dmodules=db,xml,jersey,json,ws
Parameters used:
archetypeGroupId
archetypeArtifactId
archetypeVersion
groupId
artifactId
version
muleVersion
package
transports
modules
For a description of these parameters as well as a list of all available parameters, see the table below.
To define your application as belonging to a Mule domain, add the domain specification parameters:
-DdomainGroupId=org.mycompany.domain -DdomainArtifactId=mule-domain -DdomainVersion=1.0-SNAPSHOT
Parameters used:
domainGroupId
domainArtifactId
domainVersion
For a description of these parameters as well as a list of all available parameters, see the table below.
Creating a Mule Domain
A Mule application can belong to a domain group. A domain allows sharing of resources such as connectors or libraries between applications.
To create a domain, run the following command:
mvn archetype:generate -DarchetypeGroupId=org.mule.tools.maven -DarchetypeArtifactId=maven-achetype-mule-domain -DarchetypeVersion=1.0 -DgroupId=org.mycompany.domain -DartifactId=mule-domain -Dversion=1.0-SNAPSHOT -Dpackage=org.mycompany.domain
Parameters used:
archetypeGroupId
archetypeArtifactId
archetypeVersion
groupId
artifactId
version
package
For a description of these parameters as well as a list of all available parameters, see the table below.
Creating a Complete Mule Domain Project
It is possible for several Mule applications to make use of a particular Mule domain for sharing resources; hence it makes sense to aggregate all of the applications and the domain in a single project.
To create a Maven project that includes the domain and all of the applications that will be deployed using that domain, you can use the Mule domain bundle archetype, as shown below.
mvn archetype:generate -DarchetypeGroupId=org.mule.tools.maven -DarchetypeArtifactId=maven-achetype-mule-domain-bundle -DarchetypeVersion=1.0 -DgroupId=com.mycompany -DartifactId=mule-project -Dversion=1.0-SNAPSHOT -Dpackage=com.mycompany
This command creates a Maven multi-module project with the following modules:
-
domain: This project is exactly like any project created with the Mule domain archetype. The artifact ID for this project is
${artifactId}-domain
(in this case,mule-api-domain
). -
apps: This project is a bundle project for the Mule applications that belong to this domain. Here you create the Mule applications using the Mule applications archetype.
-
domain-bundle: This project creates a bundle artifact with the domain plus the applications. This bundle project can be deployed as any domain and also deploys the domain applications.
If you’re using the Enterprise Edition (EE) distribution, set the EE
flag to true
:
-DEE=true
Parameters used:
archetypeGroupId
archetypeArtifactId
archetypeVersion
groupId
artifactId
version
package
EE
For a description of these parameters as well as a list of all available parameters, see the table below.
Available Parameters
The table below lists the available parameters along with a description and their default value, if any.
Parameter | Description | Default |
---|---|---|
|
The group ID of the archetype. |
This value must ALWAYS be set to |
|
The artifact ID of the archetype. |
This value depends on whether you are creating a Mule application, a Mule domain or a Mule domain project.
|
|
The version of the archetype. This value may change as we release new versions of the archetype. Always use the latest non-SNAPSHOT version available. |
|
|
The group ID of the application, domain or domain bundle you are creating. A good value is the reverse name of your company domain name, such as |
|
|
The artifact ID of the application, domain or domain bundle you are creating. If creating a domain bundle, try not to include the domain word in the artifact ID. |
|
|
The version of your application or domain bundle. Usually 1.0-SNAPSHOT. Your domain name, when deployed to Mule, is artifactId-version. |
|
|
The version of the Mule runtime you are going to use. Note that Mule 2.2.x is no longer supported |
|
|
A comma-separated list of the transports you are going to use within your application. |
|
|
A comma separated list of the modules you are going to use within your application. |
|
|
Boolean. Import the EE counterpart of the transports/modules you are using. |
|
|
The group ID of the domain that the application belongs to. |
empty |
|
The artifact ID of the domain that the application belongs to. |
empty |
|
The version of the domain that the application belongs to. |
empty |
|
Required by the Maven archetype, when creating a complete Mule domain project, but not used. |
See Also
-
For more information about developing Mule applications with Maven, see the overview in Using Maven with Mule, and the guides at Building a Mule Application with Maven in Studio and Using Maven in Mule.
-
Learn how to use the Mule Plugin for Maven to control Mule instances from a Maven environment
-
Learn how to import an existing Maven project into Anypoint Studio.
-
Access additional Maven Maven Reference and Configuring Maven to Work with Mule information.