API Reference

Basic functions

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

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

Parameters

maven_install

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.

Parameters

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 group-id:artifact-id:version. 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.

Maven specification functions

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

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.

Parameters

maven.artifact

Generates the data map for a Maven artifact given the available information about its coordinates.

Parameters

maven.exclusion

Generates the data map for a Maven artifact exclusion.

Parameters