Contact Us 1-800-596-4880

Maven Reference

This page summarizes reference information that is helpful for working with Maven and Mule. Refer to Using Maven with Mule for an introduction and overview.

Populating the Maven Repositories From the Command Line

You don’t usually need to do this, as it occurs automatically when creating a Maven Mule project. In case something doesn’t work as expected, you have the option of doing it manually.

To include Mule libraries as dependencies of your project, you must populate your Maven repository with these. To do this manually, you can run the populate_m2_repo script in $MULE_HOME/bin from the command line.

On Unix:


On Windows:


These scripts call $MULE_HOME/bin/populate_m2_repo.groovy which you can modify.

Deploying Mule Artifacts to a Central Maven Repository

Using a central repository can save users' time when building applications. To deploy to a central repository, you need to deploy the Mule POM files and JAR artifacts to the desired repository.

Deploying pom.xml

In your Mule installation, locate the file <MULE_HOME>/bin/populate_m2_repo.groovy and open it for editing. Locate the following line:

 "-DgroupId=${project.groupId}", "-DartifactId=${project.artifactId}",
"-Dversion=${version}", "-Dpackaging=pom",

Modify the line as shown.

 "-DgroupId=${project.groupId}", "-DartifactId=${project.artifactId}",
"-Dversion=${version}", "-Dpackaging=pom",
"-Dfile=${localPom.canonicalPath}","-Durl=http://<your_repository_ip>/nexus/content/repositories/releases", "-DrepositoryId=releases"])

For the -Durl parameter, replace your_repository_ip with the correct IP address.

Deploying the JARs

In the <MULE_HOME>/bin/populate_m2_repo.groovy file, locate the second // Install pom via maven comment. Immediately below this line is the argument definition, which reads as shown below.

def args = ["install:install-file", "-DgroupId=${pomProps.groupId}", "-DartifactId=${pomProps.artifactId}", "-Dversion=${pomProps.version}", "-Dpackaging=jar", "-Dfile=${f.canonicalPath}", "-DpomFile=${localPom.canonicalPath}"]

Modify this line as shown.

def args = ["deploy:deploy-file",
 "-DgroupId=${pomProps.groupId}", "-DartifactId=${pomProps.artifactId}",
 "-Dversion=${pomProps.version}", "-Dpackaging=jar",
"-Dfile=${f.canonicalPath}", "-DpomFile=${localPom.canonicalPath}",
"-Durl=http://${your_repository_ip}/nexus/content/repositories/releases", "-DrepositoryId=releases"]

For the -Durl parameter, replace your_repository_ip with the correct IP address.

If you wish to both install the JARs locally and deploy them remotely, you can keep both locations in the argument definition.

Referencing MuleSoft’s Enterprise Repositories

Checking JARs Included in a Project

Maven can automatically include dependencies into your project. It is possible that, when attempting to test the project outside of Maven, you may find that you need to explicitly define these dependencies for the project to work. For example, if you create a project with Studio and Maven and build it using another tool such as Apache Ant, you need to ensure that all dependencies required for the project are included in your Ant config.

To obtain a list of dependencies included in your project, run the following command:

mvn dependency:build-classpath



<project root>/pom.xml

Project Object Model file that defines settings for a Maven project describing an application. It includes all settings necessary to build the application such as build plugin configurations. Note that the pom.xml exists on a per-project basis and is distributed along with a project.

See the POM Reference at the Apache Maven online documentation for details.


<system-wide Maven directory>/settings.xml
<user home directory>/.m2/settings.xml

Contains global settings for your Maven installation. Unlike a project’s pom.xml, it defines system-wide settings and is not distributed with a project, since it can contain confidential information such as authentication credentials.

The settings.xml file may reside in two locations: in a system-wide settings folder, and in a user-specific settings folder. In the first case, it is a global settings file which defines the settings for all Maven installations on the system, regardless of user. For example:


In the second, per-user case, the file is a user settings file only relevant for a specific user’s Maven installation. In this case, the default location is the .m2 directory in the user’s home directory:


On a system with both global and user settings.xml files, the settings from both files become merged. In case of duplicate settings, the user’s settings take precedence over the global settings.

For a complete reference for this file, see Settings Reference on the Apache Maven online documentation.

Useful Commands

Locate the Maven binary and other files (Unix)

whereis mvn

Locate Maven files such as global configuration files (Unix)

locate maven

Obtain Maven version

mvn --version

This also provides other information such as the Java home directory, locale and processor architecture.

Obtain a List of Maven Commands and Options

mvn -h

Check the Manual Page for Maven (Unix)

man mvn

Create a Project

mvn archetype:generate -DartifactId=myapp -DarchetypeArtifactId=myarchetypeid -DinteractiveMode=false

Build a Project

mvn package

Clean a project

mvn clean

Generate a Site

mvn site

Obtain a List of Jars Included in Your Artifact

mvn dependency:build-classpath

Obtain the Dependency Tree for Your Artifact

mvn dependency:tree