Loading

Correct usage of Exchange with Maven

Publiseringsdato: Mar 2, 2024
Løsning

What is the Exchange Maven facade?

This is an API which has been developed internally to emulate some of the features and functionality of a Maven repository, documentation for the Maven Facade can be found here: https://anypoint.mulesoft.com/exchange/portals/anypoint-platform/f1e97bc6-315a-4490-82a7-23abe036327a.anypoint-platform/exchange-maven-facade-api-http/ this is how Maven interacts with Exchange for publishing or consuming assets.

 

What is supported by the Exchange Maven Facade?

The Exchange Maven facade is used for both consuming and publishing assets, this API is not designed to be consumed or used outside of the Maven pipeline.
As this Facade does not emulate all functionality of a Maven repository it cannot be used to completely replace an internal Maven repository, the main points to be aware of are:

  1. SNAPSHOT versions are now supported when using Version 3 of the API see the documentation here: https://docs.mulesoft.com/exchange/to-publish-assets-maven#asset-lifecycle-state for more information. Otherwise each publish operation will require a unique version number and existing versions would need to be deleted to be replaced with different code. Please bear in mind the 7 day limit on re-using existing asset names here: https://docs.mulesoft.com/exchange/to-delete-asset if deleting an asset after the 7 day period has elapsed you would need to specify a new and unique GAV (groupId, assetId and version) combination to re-upload the asset.
  2. The Exchange Maven facade does not support being used via another Maven Repository as a Proxy or Mirror repository, so this should be directly accessed to consume or publish assets via configuration in the asset pom.xml or machine settings.xml where the build is run.
  3. The Exchange Maven facade only allows for publishing Mule application related assets, so it is not possible to use Exchange as a general Maven repository to publish generic JAR files or other non-Mule specific resources, see the listing of supported asset types here: https://docs.mulesoft.com/exchange/to-publish-assets-maven
 

What is the difference between Public and Private assets in the Exchange Maven facade?

Public assets are those which are searchable and viewable in Exchange without an Anypoint login, these would include MuleSoft or 3rd party connectors which are distributed via Exchange as the repository. For instance the HTTP Connector: https://anypoint.mulesoft.com/exchange/org.mule.connectors/mule-http-connector/ can be viewed without logging into Anypoint being required. Please note that whilst the Download button is greyed out when not logged in, Maven can still consume these assets during a build without Anypoint credentials being required in the configuration.

Private assets are those which have been published into your Organizations Exchange, and can only be viewed by Anypoint users within your own Organization. These are searchable only when a user of your Organization with the required permissions is logged into the Anypoint Platform, and the URLs on which these are available will include your Organization ID.

 

How do I consume Public assets from the Exchange Maven Facade?

The required repository is added by default to the pom.xml for any new Mule 4 project:
<repository>
    <id>anypoint-exchange-v3</id>
    <name>Anypoint Exchange</name>
    <url>https://maven.anypoint.mulesoft.com/api/v3/maven</url>
    <layout>default</layout>
</repository>

and this is also detailed in the documentation regarding MuleSofts repositories here: https://docs.mulesoft.com/mule-runtime/4.4/maven-reference#configure-mule-repositories Please note that the version numbers seen in the URL relate more to Maven publish operations, assets can be consumed via the v1, v2 or v3 versions of this API without issue.
You may also add this repository directly into your settings.xml file to ensure it is available for all builds run on a given machine.

 

How do I publish and consume Private assets from the Exchange Maven Facade?

The full documentation for configuring this can be found here: https://docs.mulesoft.com/exchange/to-publish-assets-maven

If you are seeing issues with the Publishing private assets (steps documented here: https://docs.mulesoft.com/exchange/to-publish-assets-maven#publish-an-asset-to-exchange-using-maven) review the following configuration:
  • Is the Organization ID or Business Group ID configured correctly? (hereafter referred to as "Org ID", see How to know my Organization ID (Org ID) on the Anypoint Platform for details on obtaining this)
  • Ensure that the pom.xml has the <groupId> of the asset configured as the Org ID (see step 1 linked above).
  • Ensure that the the <distributionManagement> section of either the pom.xml or settings.xml has the URL configured with the correct Org ID value (see step 3 linked above).
  • Ensure that the <id> value configured for the repository in <distributionManagement> matches with the <id> value set within the <servers> tag in settings.xml or these credentials will not be associated and you will see a HTTP 401 response (see step 4 linked above).
If you are seeing issues with Consuming Private assets from your Organizations Exchange (steps documented here: https://docs.mulesoft.com/exchange/to-publish-assets-maven#consume-an-exchange-asset-with-maven) review the following configuration:
  • Ensure that the Org ID value is configured correctly in the <groupID> for the dependency and matches with the URL configured in the <distributionManagement> section of the pom.xml in the asset which was published to Exchange.
  • Ensure that the <id> values within the <repositories> section (where this repository is configured in either the pom.xml or settings.xml) and the <servers> section of settings.xml match, otherwise the credentials will not be associated and you will see a HTTP 401 response when trying to fetch the asset.
  • Ensure that the asset is visible with the expected versions available in the Exchange UI within your Web Browser.
Knowledge-artikkelnummer

001120358

 
Laster
Salesforce Help | Article