Contact Us 1-800-596-4880

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.

  1. Edit settings.xml to add a new profile with the following repositories and pluginRepositories.

    <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>
  2. Add a new pluginGroup, as shown below.

    <pluginGroups>
        ...
        <pluginGroup>org.mule.tools</pluginGroup>
        ...
     </pluginGroups>

Specifying the Mule Server for an Application or Domain

Once you have built your application or domain, you can install it to your desired Mule instance by using the -Dmule.home parameter. If this parameter is not set, the plugin installs to $MULE_HOME.

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

archetypeGroupId

The group ID of the archetype.

This value must ALWAYS be set to org.mule.tools.maven.

archetypeArtifactId

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.

  • For a Mule application: ALWAYS set to mule-archetype-project

  • For a Mule domain: ALWAYS set to maven-archetype-mule-domain

  • For a Mule domain project: ALWAYS set to maven-archetype-mule-domain-bundle

archetypeVersion

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.

groupId

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 com.mycompany.domain or org.mycompany.domain.

artifactId

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.

version

The version of your application or domain bundle. Usually 1.0-SNAPSHOT. Your domain name, when deployed to Mule, is artifactId-version.

1.0-SNAPSHOT

muleVersion

The version of the Mule runtime you are going to use. Note that Mule 2.2.x is no longer supported

3.5.0

transports

A comma-separated list of the transports you are going to use within your application.

http,jms,vm,file,ftp

modules

A comma separated list of the modules you are going to use within your application.

db,xml,jersey,json,ws

EE

Boolean. Import the EE counterpart of the transports/modules you are using.

false

domainGroupId

The group ID of the domain that the application belongs to.

empty

domainArtifactId

The artifact ID of the domain that the application belongs to.

empty

domainVersion

The version of the domain that the application belongs to.

empty

package

Required by the Maven archetype, when creating a complete Mule domain project, but not used.

See Also