Author: Rithul Kumar
This document briefs on how Maven can be used to deploy and consume Exchange assets using Maven Façade provided by Anypoint Exchange. Before that, you should be familiar with
What is Maven?
Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information.
What is Maven Façade?
The Exchange Maven Facade API lets you interact with Exchange using the Maven client to publish and consume Exchange assets as Maven dependencies. You can use the Exchange Maven Facade API for Mule applications, templates, examples, connectors, or policies.
API Prerequisites and Dependencies
- To utilize this API, you must be provisioned with an Anypoint Platform account.
- To use Maven, put the username and password for the Anypoint Platform account in the ~/.m2/settings.xml file.
- An Exchange Contributor or Exchange Administrator role is needed to publish assets using the Exchange Maven API.
- This API works with Mavenized projects, including Mule applications (Mule 3.x and 4.x), templates, examples, connectors (Mule 3.x and 4.x), and policies (Mule 4.x).
Note: You must have a unique artifact name and organization ID to publish your asset.
Publish an Asset to Exchange
- Extract your Organization ID
- Login to Anypoint Platform and click Access Management
- View your Organization and its details from the organization panel
- Update the groupId with the organization ID copied in your project pom.xml file
If you are publishing your asset to the master organization, the group ID is the same as the organization ID
If you are publishing your asset to a business group, the group ID is the same as the business group ID
- Add the other necessary fields:
The <name> property represents the visible name of the asset. If you are publishing the first version of a GA (GroupId and AssetId combination), the asset name is taken from the POM file. If there is already at least one version of the GA, the <name> property is ignored
The <description> property represents the description of the asset. If you are publishing the first version of a GA (GroupId and AssetId combination), the asset description is taken from the POM file. If there is already at least one version of the GA, the < description> property is ignored.
In Mule 3, enable the <type> property, otherwise the application won’t be displayed in Exchange.
In Mule 4 assets, do not set the <type> element, instead set the <classifier> element in the mule-maven-plugin configuration with
- Add the Maven Façade as a repository in the distribution management section in the pom file
The <id> value must be the same in the pom.xml file as in the ~/.m2/settings.xml file.
- Update the settings.xml under the ./m2 repository. This will have the anypoint platform credentials. Maven client will be accessing this settings when Maven runs.
- Open command prompt in the project location and run the following command to publish your asset to Exchange
Consume an Exchange Asset with Maven
With Maven Façade we can consume connectors, Mule applications and REST API’s published in exchange.
To consume the exchange asset
- Add the repository under the repositories element
Add the exchange asset’s groupid, artifactid and version as dependency in your pom file under the dependency section. The asset will be downloaded and added to your project.