Loading
Salesforce から送信されるメールは、承認済ドメインからのみとなります続きを読む

How to publish a Mule application as a plugin to Exchange

公開日: Mar 2, 2024
解決策

GOAL

You have created a flow in an Mule application with the purpose of re-using it in other applications, as described in KBA "How to call to a shared flow in Mule 4." and want to publish it to Anypoint Exchange. The application can be installed locally through maven but it needs extra configurations to be deployed to Exchange.


PROCEDURE

1. Check that the application pom has the below "packing" and "classifier" properties, plus the PrivateExchangeRepository both as a dependency and distribution management repository:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

    <!-- Replace ORGANIZATION_ID -->
	<groupId>ORGANIZATION_ID</groupId>
	<artifactId>poc-mule-plugin-for-exchange</artifactId>
	<version>1.0.0</version>
	<packaging>mule-application</packaging>

	<name>poc-mule-plugin-for-exchange</name>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

		<app.runtime>4.5.3</app.runtime>
		<mule.maven.plugin.version>4.0.0</mule.maven.plugin.version>
	</properties>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-clean-plugin</artifactId>
				<version>3.2.0</version>
			</plugin>
			<plugin>
				<groupId>org.mule.tools.maven</groupId>
				<artifactId>mule-maven-plugin</artifactId>
				<version>${mule.maven.plugin.version}</version>
				<extensions>true</extensions>
				<configuration>
					<classifier>mule-plugin</classifier>
				</configuration>
			</plugin>
		</plugins>
	</build>

	<dependencies>
		<dependency>
			<groupId>org.mule.connectors</groupId>
			<artifactId>mule-http-connector</artifactId>
			<version>1.9.0</version>
			<classifier>mule-plugin</classifier>
		</dependency>
		<dependency>
			<groupId>org.mule.connectors</groupId>
			<artifactId>mule-sockets-connector</artifactId>
			<version>1.2.4</version>
			<classifier>mule-plugin</classifier>
		</dependency>
	</dependencies>

	<repositories>
		<repository>
			<id>anypoint-exchange-v3</id>
			<name>Anypoint Exchange</name>
			<url>https://maven.anypoint.mulesoft.com/api/v3/maven</url>
			<layout>default</layout>
		</repository>
		<repository>
			<id>mulesoft-releases</id>
			<name>MuleSoft Releases Repository</name>
			<url>https://repository.mulesoft.org/releases/</url>
			<layout>default</layout>
		</repository>
		
		  <!-- Replace ORGANIZATION_ID -->
		  <repository>
			<id>PrivateExchangeRepository</id>
			<name>Private Exchange repository</name>
		    <url>https://maven.anypoint.mulesoft.com/api/v3/organizations/ORGANIZATION_ID/maven</url>
			<layout>default</layout>
		  </repository>
	</repositories>

	<pluginRepositories>
		<pluginRepository>
			<id>mulesoft-releases</id>
			<name>MuleSoft Releases Repository</name>
			<layout>default</layout>
			<url>https://repository.mulesoft.org/releases/</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</pluginRepository>
	</pluginRepositories>
	
	  <distributionManagement>
	    <!-- Replace ORGANIZATION_ID -->
	    <repository>
	      <id>PrivateExchangeRepository</id>
	      <name>Private Exchange repository</name>
	      <url>https://maven.anypoint.mulesoft.com/api/v3/organizations/ORGANIZATION_ID/maven</url>
	      <layout>default</layout>
	    </repository>
	  </distributionManagement>

</project>


2. In your maven settings.xml file, commonly located in the computer's .m2 folder, Make sure have a repository that matches the PrivateExchangeRepository id and has the correct credential:

        <server>
            <id>PrivateExchangeRepository</id>
            <username>~~~Client~~~</username>
            <password>${env.app_client_id}~?~${env.app_client_secret}</password>
        </server>

3. Deploy the application with the following command in a terminal:

mvn deploy

If successful, it will show the below message:
 

[INFO]   ------------------------------------------------------------
[INFO]   Publication status: completed
[INFO]   ------------------------------------------------------------
[INFO]     Steps: 
[INFO]     - Description: Publishing asset
[INFO]     - Status: completed
[INFO]     .........................................
[INFO] 
[INFO]   Your asset has been successfully published to Exchange.
[INFO]   You can check it at: https://anypoint.mulesoft.com/exchange/ORGANIZATION-ID/poc-mule-plugin-for-exchange/1.0.0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  43.467 s
[INFO] Finished at: 2024-01-31T14:28:40-03:00
[INFO] ------------------------------------------------------------------------

 

4. After it is published, you can add it as a dependency in your other mule application by adding it in those applications pom files:

<!-- Dependency added to consume the Mule plugin deployed to Exchange -->
<dependency>
	<groupId>ORGANIZATION-ID</groupId>
	<artifactId>poc-mule-plugin-for-exchange</artifactId>
	<version>1.0.0</version>
	<classifier>mule-plugin</classifier>
</dependency>

 

IMPORTANT: This is not an officially supported asset configuration (packaging as mule-application, while classifier is set as mule-plugin) so you might find limitations.

ナレッジ記事番号

001117266

 
読み込み中
Salesforce Help | Article