Nav
You are viewing an older version of this topic. To go to a different version, use the version menu at the upper-right. +

Configuring Maven to Work with Mule

When working with Maven to build Mule applications outside of Anypoint Studio, you need to configure your Maven installation to work successfully with Mule. This page covers how to maintain your POM file to add or adjust dependencies and point to the correct MuleSoft repositories, and how to modify your Maven settings.xml file to include credentials and profiles for Enterprise repositories.

Once you have modified your Maven installation, you can install Mule plugins and develop applications that reference the Mule open source or Enterprise repositories.

Developing in Maven is greatly simplified by the Maven Tools for Mule plugin, which provides Maven archetypes for building Mule applications.

This document assumes that you are working with Maven outside of Anypoint Studio, and thus are using archetypes to build Mule applications.

Setup Overview

Before you can start using Maven to create new Mule projects from the command line using archetypes, you need to: 

  1. Ensure that Maven is installed in a directory that does not include spaces.

  2. Create or maintain your pom.xml files for your applications to include references to the MuleSoft open-source repositories and any connectors, modules, or other extensions that you need to include in each application.
    If you are using Enterprise Edition, modify the settings.xml file to point to the Enterprise Customer repository and provide your credentials.

    Anypoint Exchange provides Maven dependency information.
    Click a connector asset and click Dependency Snippets to list the Maven pom.xml file dependency.

Configuring Your Maven Installation for Mule

Enabling MuleSoft Plugins

To enable MuleSoft plugins, you can modify either your project file (POM) or your settings.xml file. Edit the desired configuration file to include the following:


          
       
1
2
3
4
5
6
<settings>
    <pluginGroups>
        <pluginGroup>org.mule.tools</pluginGroup>
    </pluginGroups>
    ...
</settings>

Referencing the Open Source MuleSoft Repositories

Edit your settings.xml or project file to include the following:


          
       
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<repositories>
...
    <repository>
        <id>mulesoft-releases</id>
        <name>MuleSoft Repository</name>
        <url>http://repository.mulesoft.org/releases/</url>
        <layout>default</layout>
    </repository>
    <repository>
        <id>mulesoft-snapshots</id>
        <name>MuleSoft Snapshot Repository</name>
        <url>http://repository.mulesoft.org/snapshots/</url>
        <layout>default</layout>
    </repository>
...
</repositories>

If the dependencies that you need are not already present, add them as shown.


          
       
1
2
3
4
5
6
7
8
9
<dependencies>
...
    <dependency>
        <groupId>GROUP ID OF DEPENDENCY</groupId>
        <artifactId>ARTIFACT ID OF DEPENDENCY</artifactId>
        <version>VERSION OF DEPENDENCY</version>
    </dependency>
...
<dependencies>

For example, if you were adding the dependency for the Salesforce connector:


          
       
1
2
3
4
5
6
7
8
9
<dependencies>
...
    <dependency>
        <groupId>org.mule.modules</groupId>
        <artifactId>mule-module-sfdc</artifactId>
        <version>LATEST</version>
    </dependency>
...
<dependencies>

Not sure what the dependency details are for a connector that you need? Refer to the connector-specific Maven instructions on the connectors site.

Referencing the Public MuleSoft Repositories

This repository includes third party libraries used by Mule components. If Maven cannot resolve all of the library dependencies needed by the Mule components using solely the official MuleSoft release and snapshot repositories, then please consider adding the following MuleSoft Public repository:


          
       
1
2
3
4
5
6
7
8
9
10
<repositories>
...
    <repository>
        <id>mulesoft-public</id>
        <name>MuleSoft Public Repository</name>
        <url>https://repository.mulesoft.org/nexus/content/repositories/public/</url>
        <layout>default</layout>
    </repository>
...
</repositories>

Referencing MuleSoft’s Enterprise Repositories

This section assumes that you have acquired an Enterprise License and credentials for the MuleSoft Enterprise Maven customer repository, which allows you to access Mule Enterprise modules, connectors, and other components not included in the trial or community versions. If you are a MuleSoft customer and do not have access to the repository, contact MuleSoft Support and request enterprise credentials.

To configure Maven to access the MuleSoft Customer Repository, you need to make additions to the settings.xml config file on all workstations that require access. Your .m2 directory may already contain a configuration file called settings.xml. Note that this file is not mandatory; Maven uses default parameters if the file is not present. If you don’t have a settings.xml file at all, create it inside the ~/.m2 folder. Read more about the settings.xml file in the Maven documentation.

  1. Open the file <USER_HOME>/.m2/settings.xml for editing.

  2. Add the following to the servers section.

    
                 
              
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
    <servers>
    ...
        <server>
    
            <id>MuleRepository</id>
            <username>YOUR_ID</username>
            <password>YOUR_PASSWORD</password>
    
        </server>
    ...
    </servers>
  3. Add the following to the profiles section:

    
                 
              
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    
    <profiles>
    ...
        <profile>
    
            <id>Mule</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <repositories>
                <repository>
                    <id>MuleRepository</id>
                    <name>MuleRepository</name>
                    <url>https://repository.mulesoft.org/nexus-ee/content/repositories/releases-ee/</url>
                    <layout>default</layout>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
    
        </profile>
    ...
    </profiles>
    

See Also