These are the basic functions to get started.
To use these functions, load them at the top of your BUILD file. For example:
load("@rules_jvm_external//:defs.bzl", "maven_install", "artifact")artifact(coordinates, repository_name)
A helper macro to translate Maven coordinates into a Bazel target label.
For example:
artifact("com.google.guava:guava") translates into @maven//:com_google_guava_guava
artifact("com.google.guava:guava", repository_name = "custom_maven") translates into @custom_maven//:com_google_guava_guava
coordinates |
required. |
repository_name |
optional. default is "maven"
The name of the `maven_install` declaration in the WORKSPACE file containing this artifact. |
maven_install(name, repositories, artifacts, fetch_sources, use_unsafe_shared_cache)
Resolves and fetches artifacts transitively from Maven repositories.
This macro runs a repository rule that invokes the Coursier CLI to resolve and fetch Maven artifacts transitively.
name |
optional. default is "maven"
A unique name for this Bazel external repository. |
repositories |
optional. default is []
A list of Maven repository URLs, specified in lookup order. Supports URLs with HTTP Basic Authentication, e.g. "https://username:password@example.com". |
artifacts |
optional. default is []
A list of Maven artifact coordinates in the form of |
fetch_sources |
optional. default is False
Additionally fetch source JARs. |
use_unsafe_shared_cache |
optional. default is False
Download artifacts into a persistent shared cache on disk. Unsafe as Bazel is currently unable to detect modifications to the cache. |
These are helper functions to specify more information about Maven artifacts and
repositories in maven_install.
To use these functions, load the maven struct at the top of your BUILD file:
load("@rules_jvm_external//:specs.bzl", "maven")maven.repository(url, user, password)
Generates the data map for a Maven repository specifier given the available information.
If both a user and password are given as arguments, it will include the access credentials in the repository spec. If one or both are missing, it will just generate the repository url.
url |
required.
A string containing the repository url (ex: "https://maven.google.com/"). |
user |
optional. default is None
A username for this Maven repository, if it requires authentication (ex: "johndoe"). |
password |
optional. default is None
A password for this Maven repository, if it requires authentication (ex: "example-password"). |
maven.artifact(group, artifact, version, packaging, classifier, override_license_types, exclusions)
Generates the data map for a Maven artifact given the available information about its coordinates.
group |
required.
The Maven artifact coordinate group name (ex: "com.google.guava"). |
artifact |
required.
The Maven artifact coordinate artifact name (ex: "guava"). |
version |
required.
The Maven artifact coordinate version name (ex: "27.0-jre"). |
packaging |
optional. default is None
The Maven packaging specifier (ex: "jar"). |
classifier |
optional. default is None
The Maven artifact classifier (ex: "javadoc"). |
override_license_types |
optional. default is None
An array of Bazel license type strings to use for this artifact's rules (overrides autodetection) (ex: ["notify"]). |
exclusions |
optional. default is None
An array of exclusion objects to create exclusion specifiers for this artifact (ex: maven.exclusion("junit", "junit")). |
maven.exclusion(group, artifact)
Generates the data map for a Maven artifact exclusion.
group |
required.
The Maven group name of the dependency to exclude, e.g. "com.google.guava". |
artifact |
required.
The Maven artifact name of the dependency to exclude, e.g. "guava". |