---
schema_version: "1"
id: 6301e982bbbda8eef820dd682327a5e03d2f06989d79af5779708fbd97fedf38
title: Packaging and Deploying DataWeave Libraries
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.9/dataweave-maven-plugin.md
canonical_url: https://docs.mulesoft.com/dataweave/2.9/dataweave-maven-plugin
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 6f4fa69c1a0b72a2feef92cf6b5842c180758270145c186938102970457d5d55
description: MuleSoft Documentation Site
release: "2.9"
latest: false
---
---
product: DataWeave
version: 2.9
---

# Packaging and Deploying DataWeave Libraries

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

Use the Apache Maven plugin for DataWeave to integrate the packaging and deployment of your
DataWeave libraries with your Maven lifecycle.

The plugin enables you to run six main goals:

- `compile`  
  Compiles the source code for your DataWeave library.

- `test`  
  Tests the compiled source code using the
  [DataWeave testing framework](https://docs.mulesoft.com/dataweave/2.9/dataweave-testing-framework).

- `data-weave:generate-docs`  
  Automatically generates the documentation for your DataWeave library.

- `package`  
  Packages the compiled code in a `.jar` file.

- `data-weave:deploy-docs`  
  Uploads the auto-generated documentation for your DataWeave library to Anypoint Exchange.

- `deploy`  
  Automatically uploads your DataWeave library to the deployment target and uploads the
  auto-generated documentation to Exchange.

## Add the Maven Plugin to a Project

To enable the Maven plugin for DataWeave in your project:

- Add the following Maven dependency to your project’s `pom.xml` file:

  ```xml
  <plugin>
    <groupId>org.mule.weave</groupId>
    <artifactId>data-weave-maven-plugin</artifactId>
    <version>2.9.0</version>
    <extensions>true</extensions>
  </plugin>
  ```

- Add the following repositories to your project’s `pom.xml` file::

  ```xml
  <pluginRepositories>
      <pluginRepository>
          <id>mule-releases</id>
          <url>https://repository-master.mulesoft.org/nexus/content/repositories/releases</url>
      </pluginRepository>
      <pluginRepository>
          <id>mule-snapshots</id>
          <url>https://repository-master.mulesoft.org/nexus/content/repositories/snapshots</url>
      </pluginRepository>
  </pluginRepositories>
  ```

## Compile a DataWeave Library

Run the `compile` goal to compile your DataWeave library from source code, for example:

```console
mvn compile
```

## Test a DataWeave Library

Run the `test` goal to execute the DataWeave test suite included in your library, for example:

```console
mvn test
```

The Maven plugin for DataWeave uses the [DataWeave testing framework](https://docs.mulesoft.com/dataweave/2.9/dataweave-testing-framework)
to run your test suite, which supports configuring additional parameters when you run the `test`
goal.

### Configure the Test Suite

Inside the `plugin` configuration, add a `tests` element configured to use parameters that meet your
testing needs:

<table><colgroup><col> <col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p><code>output</code></p></div></div></td><td><div><div><p><code>String</code></p></div></div></td><td><div><div><p><code>${project.build.directory}/data-weave-test-reports</code></p></div></div></td><td><div><div><p>Specifies the path for the directory in which all the auto-generated reports are created when the test runs.</p></div></div></td></tr><tr><td><div><div><p><code>htmlReport</code></p></div></div></td><td><div><div><p><code>boolean</code></p></div></div></td><td><div><div><p><code>true</code></p></div></div></td><td><div><div><p>When this property is set to <code>true</code>, the test suite generates an HTML report about the execution.</p></div></div></td></tr><tr><td><div><div><p><code>coverageEnabled</code></p></div></div></td><td><div><div><p><code>boolean</code></p></div></div></td><td><div><div><p><code>false</code></p></div></div></td><td><div><div><p>When this property is set to <code>true</code>, the test suite generates a coverage report about the execution.</p></div></div></td></tr><tr><td><div><div><p><code>coverageFormat</code></p></div></div></td><td><div><div><p><code>String</code></p></div></div></td><td><div><div><p><code>sonar</code></p></div></div></td><td><div><div><p>Specifies the format for the coverage report, one of:</p></div><div><ul><li><p><code>sonar</code><br>Generates a valid <a href="https://www.sonarsource.com/products/sonarqube/" target="_blank" rel="noopener">Sonar</a> coverage report for your test suite.</p></li><li><p><code>html</code><br>Generates an HTML coverage report for your test suite.</p></li></ul></div></div></td></tr><tr><td><div><div><p><code>runnerLogForkedProcessCommand</code></p></div></div></td><td><div><div><p><code>boolean</code></p></div></div></td><td><div><div><p><code>false</code></p></div></div></td><td><div><div><p>When set to <code>true</code>, logs the command used to launch the test runner process.</p></div></div></td></tr><tr><td><div><div><p><code>runnerEnvironmentVariables</code></p></div></div></td><td><div><div><p><code>Map</code></p></div></div></td><td><div><div><p><code>null</code></p></div></div></td><td><div><div><p>A set of additional environment variables to pass to the test runner process.</p></div></div></td></tr><tr><td><div><div><p><code>runnerSystemProperties</code></p></div></div></td><td><div><div><p><code>Map</code></p></div></div></td><td><div><div><p><code>null</code></p></div></div></td><td><div><div><p>A set of additional system properties to pass to the test runner process.</p></div></div></td></tr><tr><td><div><div><p><code>runnerArgLine</code></p></div></div></td><td><div><div><p><code>boolean</code></p></div></div></td><td><div><div><p><code>null</code></p></div></div></td><td><div><div><p>A set of additional JVM options to pass to the test runner process.</p></div></div></td></tr><tr><td><div><div><p><code>runnerJvmDebug</code></p></div></div></td><td><div><div><p><code>boolean</code></p></div></div></td><td><div><div><p><code>false</code></p></div></div></td><td><div><div><p>When set to <code>true</code>, enables remote debugging for the test runner JVM.</p></div></div></td></tr></tbody></table>

### Test Configuration Example

The following example enables the `sonar` coverage report and disables `htmlReport` in a project.

Example `pom.xml` file

```xml
<plugin>
  <groupId>org.mule.weave</groupId>
  <artifactId>data-weave-maven-plugin</artifactId>
  <version>2.9.0</version>
  <extensions>true</extensions>
  <configuration>
    ...
    <tests>
      <htmlReport>false</htmlReport>
      <coverageEnabled>true</coverageEnabled>
      <coverageFormat>sonar</coverageFormat>
    </tests>
    ...
  </configuration>
</plugin>
```

## Generate Documentation for a DataWeave Library

Run the `data-weave:generate-docs` goal to auto-generate the documentation for your DataWeave
library, for example:

```console
mvn prepare-package
```

Alternatively, you can also run:

```console
mvn data-weave:generate-docs
```

### Configure the Automated Docs Generation

Inside the `plugin` configuration, add a `docs` element configured with parameters that meet your
documentation needs:

<table><colgroup><col> <col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p><code>output</code></p></div></div></td><td><div><div><p><code>String</code></p></div></div></td><td><div><div><p><code>${project.build.directory}/data-weave-docs</code></p></div></div></td><td><div><div><p>The output directory in which the documentation files are created.</p></div></div></td></tr><tr><td><div><div><p><code>template</code></p></div></div></td><td><div><div><p><code>String</code></p></div></div></td><td><div><div><p><code>exchange_markdown</code></p></div></div></td><td><div><div><p>The template to use for the auto-generated documentation, one of:</p></div><div><ul><li><p><code>exchange_markdown</code><br>Generates the documentation in a Markdown format that is compliant with <a href="https://anypoint.mulesoft.com/exchange/portals/anypoint-platform/f1e97bc6-315a-4490-82a7-23abe036327a.anypoint-platform/exchange-experience-api/" target="_blank" rel="noopener">Exchange</a>.</p></li><li><p><code>markdown</code><br>Generates the documentation in Markdown format.</p></li><li><p><code>asciidoc</code><br>Generates the documentation in AsciiDoc format.</p></li></ul></div><div><p>Valid values are <code>exchange_markdown</code>, <code>markdown</code>, or <code>asciidoc</code>.</p></div></div></td></tr><tr><td><div><div><p><code>homePage</code></p></div></div></td><td><div><div><p><code>String</code></p></div></div></td><td><div><div><p><code>null</code></p></div></div></td><td><div><div><p>Specifies the path to a custom Markdown file to add in the home page. The file must be generated by the <code>markdown</code> or <code>exchange_markdown</code> template.</p></div></div></td></tr><tr><td><div><div><p><code>favicon</code></p></div></div></td><td><div><div><p><code>String</code></p></div></div></td><td><div><div><p><code>null</code></p></div></div></td><td><div><div><p>Specifies the path to the image file (<code>png</code> or <code>jpg</code>) to use as the asset icon in the Exchange portal.</p></div></div></td></tr></tbody></table>

### Docs Generation Example

The following example shows how to configure both a custom home page and a specific favicon to
include in the Exchange portal home page of your DataWeave library:

Example `pom.xml` file:

```xml
<plugin>
  <groupId>org.mule.weave</groupId>
  <artifactId>data-weave-maven-plugin</artifactId>
  <version>2.9.0</version>
  <extensions>true</extensions>
  <configuration>
    ...
    <docs>
      <homePage>${project.basedir}/README.md</homePage>
      <favicon>${project.basedir}/src/main/resources/favicon/parrot.jpg</favicon>
    </docs>
    ...
  </configuration>
</plugin>
```

## Deploy DataWeave Libraries and Upload Documentation to Exchange

Before uploading DataWeave libraries to Exchange, ensure that the `pom.xml` file includes all
MuleSoft repositories and your credentials for Maven to access the enterprise repository. See
[Publish an Asset to Exchange Using Maven](https://docs.mulesoft.com/exchange/to-publish-assets-maven#publish-an-asset-to-exchange-using-maven)
for instructions to set up your DataWeave library.

After reviewing the `pom.xml` file, run the `deploy` goal to deploy the DataWeave library to the
deployment target, and upload the generated documentation to Exchange, for example:

```console
mvn deploy
```

### Skip Exchange Documentation Upload

You can skip the Exchange documentation upload when deploying a DataWeave project by setting the
`skipDeployDocs` system property to `true`:

```console
mvn deploy -DskipDeployDocs=true
```

### Upload the Documentation to Exchange

Alternatively, you can run the `data-weave:deploy-docs` goal to upload the generated documentation
to Exchange without deploying the DataWeave library, for example:

```console
mvn data-weave:deploy-docs
```

## DataWeave Library Structure Reference

When designing your DataWeave library, use the basic components `src` and `pom.xml`:

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Component</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p><code>src</code></p></div></div></td><td><div><div><p>Folder</p></div></div></td><td><div><div><p>The source directory for your DataWeave library’s production source code and tests.</p></div></div></td></tr><tr><td><div><div><p><code>pom.xml</code></p></div></div></td><td><div><div><p>Descriptor</p></div></div></td><td><div><div><p>The POM file of your DataWeave library. This file describes all of your library’s required dependencies.</p></div></div></td></tr></tbody></table>

## Source Directory Reference

The directory structure of a DataWeave library comprises the `src/main` and `src/test` folders.

### src/main

`src/main` is the root folder for all the production source code of the DataWeave library.

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Folder</th><th>Folder Type</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p><code>src/main/dw</code></p></div></div></td><td><div><div><p>source</p></div></div></td><td><div><div><p>The root folder of the DataWeave library source code files.</p></div></div></td></tr><tr><td><div><div><p><code>src/main/resources</code></p></div></div></td><td><div><div><p>resource</p></div></div></td><td><div><div><p>Contains the application resources, such as XML, JSON, and properties files.</p></div></div></td></tr></tbody></table>

### src/test

`src/test` is the root folder for all the test source code of the DataWeave library.

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Folder</th><th>Folder Type</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p><code>src/test/dw</code></p></div></div></td><td><div><div><p>source</p></div></div></td><td><div><div><p>The root folder of the test cases used to validate the DataWeave library.</p></div></div></td></tr><tr><td><div><div><p><code>src/test/resources</code></p></div></div></td><td><div><div><p>resource</p></div></div></td><td><div><div><p>Contains resources, such as XML, JSON, and properties files. This folder also contains files required to run your test suite.</p></div></div></td></tr></tbody></table>

## See Also

- [DataWeave Extension](https://docs.mulesoft.com/dataweave/2.9/dataweave-extension)

- [Testing DataWeave Libraries and Modules](https://docs.mulesoft.com/dataweave/2.9/dataweave-testing-framework)

- [Installing and Using the DataWeave Extension](https://docs.mulesoft.com/dataweave/2.9/dataweave-extension-plugin)
