Getting started Community Training Tutorials Documentation APIs, AI & Tools
<plugin>
<groupId>org.mule.weave</groupId>
<artifactId>data-weave-maven-plugin</artifactId>
<version>2.9.0</version>
<extensions>true</extensions>
</plugin>
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.
To enable the Maven plugin for DataWeave in your project:
Add the following Maven dependency to your project’s pom.xml file:
<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::
<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>
Run the compile goal to compile your DataWeave library from source code, for example:
mvn compile
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.
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 |
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>
The Maven plugin for DataWeave can run cryptographic taint analysis at compile time to help identify potential security vulnerabilities in your DataWeave code. The analysis tracks literal algorithm values that flow into parameters annotated with @CryptographicSink and causes the build to fail when an algorithm matches your configured insecure list. For more details about the annotation, see Crypto Annotations.
Inside the plugin configuration, add cryptoTaintAnalysisSettings with values that match your security requirements:
| Name | Type | Default | Description |
|---|---|---|---|
|
|
|
When set to |
|
|
|
Comma-separated list of cryptographic algorithms that your organization considers insecure. The plugin reports a compilation error when one of these algorithms reaches a |
|
|
|
Comma-separated list of DataWeave modules to flag as sensitive. Use DataWeave module notation with the |
This example enables taint analysis and configures both insecure algorithms and sensitive modules:
pom.xml file<plugin>
<groupId>org.mule.weave</groupId>
<artifactId>data-weave-maven-plugin</artifactId>
<version>2.9.0</version>
<extensions>true</extensions>
<configuration>
...
<cryptoTaintAnalysisSettings>
<enabled>true</enabled>
<insecureAlgorithms>MD5,SHA1,DES,RC4</insecureAlgorithms>
<sensitiveModules>dw::crypto::CryptoModule,dw::security::HashModule,dw::util::SecurityModule</sensitiveModules>
</cryptoTaintAnalysisSettings>
...
</configuration>
</plugin>
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
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 ( |
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>
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
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. |
The directory structure of a DataWeave library comprises the src/main and src/test folders.
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 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. |