Contact Us 1-800-596-4880

External Libraries

Connectors and Modules sometimes depend on external libraries that cannot be packaged inside the connector due to licensing, versioning, custom libs, and so on.

The Database connector is an example of a case where the same base code you can work with several different drivers and several versions of a same driver. The solution to this problem is ask users of the Database connector to identify the JDBC Driver to use for the database to which they want to connect.

Usage

To declare that the Connector or Module requires an external library to work in a Mule app, you need to annotate your @Extension, Configuration, or ConnectionProvider class with the @ExternalLib annotation and provide properties that will help the Mule App developer understand how to configure these libraries.

To help your users configure libraries more easily, it is highly recommended that you fill out all the properties that the annotation provides, for example:

+

@ExternalLib(name = "MySQL JDBC Driver",
description = "A JDBC driver that supports connection to the MySQL Database",
nameRegexpMatcher = "(.*)\\.jar",
requiredClassName = "com.mysql.jdbc.Driver",
coordinates = "mysql:mysql-connector-java:5.1.44")
public class MySqlConnectionProvider implements ConnectionProvider<Connection> {
  //
}

+ Note that a Connector can require multiple external libraries. The @ExternalLib annotation can be used many times as needed.

Properties

Property Required Type Description

name

true

String

Friendly name to be displayed in the UI.

description

false

String

Short description of the external library.

nameRegexpMatcher

false

String

Regular expression used to match the name of the library’s file and validate that the library specified by your user is the correct one.

requiredClassName

false

String

(Only for Java Libraries) Name of a Class that will be present in the external library. This will be used for validating whether the library specified by your user is the correct one.

type

true

Enum

  • NATIVE: Native library dependency

  • JAR: JAR file dependency

  • DEPENDENCY: External dependency (for example, an obtained dependency that is specified in the pom.xml if you are using Maven)

For custom connectors, all Maven dependencies must be accessible from Anypoint Exchange. Maven dependencies published to private or public repositories are not accessible from Anypoint Exchange.

You can publish Maven dependencies before publishing your custom connector by using one of the following options:

  • Publish the Maven dependencies on Anypoint Exchange to make them available to your Anypoint Platform organization.

  • Publish the Maven dependencies on the Maven Central repository to make them publicly available.

You cannot use MuleSoft repositories for publishing.

coordinates

false

String

Maven coordinates suggestion that indicates where the required library can be found. They should follow Maven’s convention groupId:artifactId:packaging:classifier:version.

optional

false

Boolean

Indicates whether the library is not required for the Connector or Module to work.