<plugin>
<groupId>org.mule.weave</groupId>
<artifactId>data-weave-maven-plugin</artifactId>
<version>2.9.0</version>
<extensions>true</extensions>
</plugin>
xml
Packaging and Deploying DataWeave Libraries
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. -
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: -
Add the following repositories to your project’s
pom.xml
file::<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>
xml
Compile a DataWeave Library
Run the compile
goal to compile your DataWeave library from source code, for example:
mvn compile
Test a DataWeave Library
Run the test
goal to execute the DataWeave test suite included in your library, for example:
mvn test
The Maven plugin for DataWeave uses the 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:
Name | Type | Default | Description |
---|---|---|---|
|
|
|
Specifies the path for the directory in which all the auto-generated reports are created when the test runs. |
|
|
|
When this property is set to |
|
|
|
When this property is set to |
|
|
|
Specifies the format for the coverage report, one of:
|
|
|
|
When set to |
|
|
|
A set of additional environment variables to pass to the test runner process. |
|
|
|
A set of additional system properties to pass to the test runner process. |
|
|
|
A set of additional JVM options to pass to the test runner process. |
|
|
|
When set to |
Test Configuration Example
The following example enables the sonar
coverage report and disables htmlReport
in a project.
pom.xml
file<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>
xml
Generate Documentation for a DataWeave Library
Run the data-weave:generate-docs
goal to auto-generate the documentation for your DataWeave library, for example:
mvn prepare-package
Alternatively, you can also run:
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:
Name | Type | Default | Description |
---|---|---|---|
|
|
|
The output directory in which the documentation files are created. |
|
|
|
The template to use for the auto-generated documentation, one of:
Valid values are |
|
|
|
Specifies the path to a custom Markdown file to add in the home page. The file must be generated by the |
|
|
|
Specifies the path to the image file ( |
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:
pom.xml
file:<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>
xml
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 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:
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
:
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:
mvn data-weave:deploy-docs
DataWeave Library Structure Reference
When designing your DataWeave library, use the basic components src
and pom.xml
:
Component | Type | Description |
---|---|---|
|
Folder |
The source directory for your DataWeave library’s production source code and tests. |
|
Descriptor |
The POM file of your DataWeave library. This file describes all of your library’s required dependencies. |
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.
Folder | Folder Type | Description |
---|---|---|
|
source |
The root folder of the DataWeave library source code files. |
|
resource |
Contains the application resources, such as XML, JSON, and properties files. |
src/test
src/test
is the root folder for all the test source code of the DataWeave library.
Folder | Folder Type | Description |
---|---|---|
|
source |
The root folder of the test cases used to validate the DataWeave library. |
|
resource |
Contains resources, such as XML, JSON, and properties files. This folder also contains files required to run your test suite. |