---
schema_version: "1"
id: 7ede82f5ed89e7f8a4cadc687a223adeee1ae7da8b55d17295f11cc879214180
title: Package a Mule Application
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-runtime/4.4/package-a-mule-application.md
canonical_url: https://docs.mulesoft.com/mule-runtime/4.4/package-a-mule-application
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 2c71f4d22f661c254b5cbe8322c8a3dcba20fa88953a41a6b593905ce04b0cbd
description: MuleSoft Documentation Site
release: "4.4"
latest: false
---
---
product: Mule Runtime
version: 4.4
---

# Package a Mule Application

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

> [!WARNING] Mule Maven plugin versions 3.0.0, 3.1.0, 3.1.1, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6,
> 3.1.7, and 3.8.3 are deprecated.

You can package your Mule applications using Mule Maven Plugin(command line) or Anypoint Studio. See
[Exporting Projects from Studio](https://docs.mulesoft.com/studio/import-export-packages#export-project-studio) for
details about this procedure.

Mule applications are packaged into a deployable JAR file that you can later deploy to a running
Mule runtime engine. The package contains the application and all its dependencies whether those be
JAR files required by the application or by its plugins.

Every Mule application has two descriptors. These descriptors define your Mule application’s
dependencies:

- A `mule-artifact.json` file.  
  This file describes how your application is composed.

- A `pom.xml` file.  
  This file describes all the dependencies required by the package to work properly.

## Compatibility

Mule 4 applications are compatible with the following Anypoint Studio and Mule Maven Plugin
versions:

- Anypoint Studio 7.x

- Mule Maven Plugin 3.x

## Prerequisites

- Add the Mule Maven Plugin to your project

  See [Add the Mule Maven Plugin to a Mule Project](https://docs.mulesoft.com/mule-runtime/4.4/mmp-concept#add-mmp) for instructions.

## Mule Application Structure Reference

At design time, your Mule application must have at least these three basic components:

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Component</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p><code>src</code></p></td><td><p>Folder</p></td><td><p>The source directory for your application’s productive source code and tests.<br>See a reference for this folder below.</p></td></tr><tr><td><p><code>pom.xml</code></p></td><td><p>Descriptor</p></td><td><p>The POM file of your Mule application.<br>This file describes all of your application’s required dependencies.</p></td></tr><tr><td><p><code>mule-artifact.json</code></p></td><td><p>Descriptor</p></td><td><p>The mule-artifact file of your Mule application.<br>This file describes how your Mule application is composed.</p></td></tr></tbody></table>

These three components are mandatory. If one of them is missing, the project cannot be packaged into
a deployable JAR file.  
Additionally, the packaging process does not consider any other directory or file in the root folder
of your Mule application.

## Source Directory Reference

The `src` directory has two main folders: `main` and `test`.  
The plugin does not consider any other directory inside `src` when packaging the application.

### src/main

src/main is the root folder for all the productive source code of the application.

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Folder</th><th>Folder Type</th><th>Description</th></tr></thead><tbody><tr><td><p><code>src/main/mule</code></p></td><td><p>source</p></td><td><p>The root folder of the Mule configuration files.<br>It can contain nested folders, in the way of Java packages.</p><p>This folder is mandatory.</p></td></tr><tr><td><p><code>src/main/resources</code></p></td><td><p>resource</p></td><td><p>It contains the application resources, such as XML, JSON, and properties files.<br>Jar files located here are loaded by the application classloader but as plain file resources.</p></td></tr></tbody></table>

The packaging process sends all files inside `src/main/mule` and `src/main/resources` to the root
directory of your binary package.  
Nested folders within `src/main/mule` are preserved as directories within the root directory of the
binary package.

### src/test

src/test is the root folder for all the test source code of the application.

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Folder</th><th>Folder Type</th><th>Description</th></tr></thead><tbody><tr><td><p><code>src/test/java</code></p></td><td><p>source</p></td><td><p>It’s the root folder of the test classes used to validate the custom Java code of the app.<br>It follows the conventions of any normal Java application.</p></td></tr><tr><td><p><code>src/test/munit</code></p></td><td><p>source</p></td><td><p>It contains the MUnit source code.<br>It can contain nested folders in the way of packages.</p></td></tr><tr><td><p><code>src/test/resources</code></p></td><td><p>resource</p></td><td><p>It contains resources, such as XML, JSON, and properties files.<br>This folder also contains files describing metadata being referenced in the <code>mule-config.xml</code>.</p></td></tr></tbody></table>

## Package a Mule Application

From the command line in your project’s folder, execute the package goal:

```console
mvn clean package
```

The plugin packages your application and creates the deployable JAR file into the target directory
within your project’s folder.

> [!NOTE] If there is a dependency version conflict in your `pom.xml`, the latest version is used.

## Create an Application Package to Import into Anypoint Studio

To generate a JAR file that can be imported into Anypoint Studio, you must package your application
using the `-DattachMuleSources` parameter to include source files and metadata that Studio requires
to reimport the deployable file as an open Mule project into your workspace.

From the command line in your project’s folder, run:

```console
mvn clean package -DattachMuleSources
```

The `-DattachMuleSources` parameter tells the plugin to add a `mule-src` folder inside the
`META-INF` directory with an exact copy of your application structure at design time. This option
also packages project modules and dependencies required to create a functioning Mule deployable
archive file that can be deployed into a Mule runtime engine.

## Create a Lightweight Package

You can skip bundling the actual modules and external dependencies required to run the Mule
application in a Mule runtime engine, and create a lightweight package with only the source files
and metadata required to import the JAR package back into Anypoint Studio.

From the command line in your project’s folder, run:

```console
mvn clean package -DlightweightPackage
```

When you specify this parameter, the plugin creates a lightweight JAR file that does not include any
dependencies declared in the Mule application’s `pom.xml` file. This JAR file cannot be deployed to
a Mule runtime engine, it only offers a way to archive just the Mule application’s source files. The
result of this Maven parameter is the same as unchecking **Include project modules and
dependencies** when exporting the Mule application from Anypoint Studio.

## Specify Multiple Parameters

You can also combine the parameters together to create a lightweight Mule application package that
also includes the source files and metadata to import the package back into Anypoint Studio.

From the command line in your project’s folder, run:

```console
mvn clean package -DattachMuleSources -DlightweightPackage
```

## Exclude Files from the Application Package

When you package an application, you can exclude certain files or directories. Create a
`_muleExclude` file at the project root directory and edit its content to set the exclusion rules.

Each line in a `_muleExclude` file specifies a rule that follows the
[glob pattern](https://docs.oracle.com/javase/tutorial/essential/io/fileOps.html#glob).

For example, consider the following `_muleExclude` file which contains two exclusion rules:

fileToBeExcluded.json \*\*/src/main/resources/local\_directory

- The first line indicates that all files named `fileToBeExcluded.json`, inside any directory, are
  excluded from the application package.

- The second line indicates that only the directory named `local_directory` located under
  `src/main/resources` is excluded from the package.  
  If `**/src/main/resources/local_directory` is replaced with `local_directory` then all directories
  named `local_directory`, inside the project, are excluded from the application package.

## See Also

- [Exporting Projects from Studio](https://docs.mulesoft.com/studio/import-export-packages#export-project-studio)

- [Mule Maven Plugin](https://docs.mulesoft.com/mule-runtime/4.4/mmp-concept)
