Contact Us 1-800-596-4880

Upload Custom Policies and Publish Assets to Exchange Using the Maven Client

There are differences between Anypoint Platform Private Cloud Edition (Anypoint Platform PCE) and the cloud version of Anypoint Platform that you must consider when uploading custom policies and publishing assets to Anypoint Exchange using the Maven client.

See the following documentation for the cloud version of Anypoint Platform for details:

Perform the following steps for Anypoint Platform PCE:

  1. Add the server and repository sections in the settings.xml file to set up the archetype for your project:

    The following snippet shows the relevant sections:

        ...
        <server>
           <id>apce-repository</id>
           <username>myusername</username>
           <password>mypassword</password>
        </server>
        ...
        <repository>
           <id>apce-repository</id>
           <name>Anypoint PCE Repository</name>
           <url>https://${ANYPOINT_DNS}/exchange/maven</url>
        </repository>
        ...

    In the following examples, ${ANYPOINT_DNS} is set to your DNS for Anypoint Platform PCE. The username and password must correspond with your installation.

  2. Generate the archetype:

    Follow the standard process: Getting started with Custom Policies development. For example:

    mvn -Parchetype-repository archetype:generate \
    -DarchetypeGroupId=org.mule.tools \
    -DarchetypeArtifactId=api-gateway-custom-policy-archetype \
    -DarchetypeVersion=1.0.0 \
    -DgroupId=${orgId} \
    -DartifactId=${policyName} \
    -Dversion=1.0.0-SNAPSHOT \
    -Dpackage=mule-policy
  3. Replace the exchange.url in the pom.xml file. By default, exchange.url points to the cloud version of Anypoint Platform. maven.anypoint.mulesoft.com must point to the Anypoint Platform PCE endpoint:

    <exchange.url>https://${ANYPOINT_DNS}/exchange/maven/api/v1/organizations/${orgId}/maven</exchange.url>

    The repositoryId must match the one you configured for Maven in the settings.xml file.

  4. Package the custom policy.

    Follow the same process as documented for the cloud version of Anypoint Platform in Packaging a Custom Policy.

  5. Upload the custom policy.

    Follow the same process as documented for the cloud version of Anypoint Platform in Uploading a Custom Policy to Exchange.

    If you receive an error similar to:

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project ${policyName}:
    Failed to retrieve remote metadata ${groupId}:${policyName}:1.0.0-SNAPSHOT/maven-metadata.xml: Could not transfer metadata ${orgId}:${policyName}:1.0.0-SNAPSHOT/maven-metadata.xml from/to exchange-server (https://${ANYPOINT_DNS}/exchange/maven/api/v1/organizations/${orgId}/maven): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]

    This means the certificate of the platform is not trusted by the local Maven. The solution is to trust the certificate in the environment where Maven is running, as shown in the following example:

    keytool -printcert -sslserver ${ANYPOINT_DNS}:443 -rfc > /tmp/anypoint.crt
    keytool -importcert -alias my-company.com -keystore /etc/ssl/certs/java/cacerts -storepass changeit -file /tmp/anypoint.crt

    In the previous example, $ANYPOINT_DNS is set to the DNS for Anypoint Platform PCE. Replace the location and password for your JVM’s truststore.

  6. Verify your policy was uploaded by directly visiting https://${ANYPOINT_DNS}/exchange/?type=policy or https://${ANYPOINT_DNS}/exchange/${orgID}/${artifactId}/.

    For an API managed by Mule 4 or later, the policy is displayed in the Apply Policy dialog.