Please note The lock file format was changed in rules_jvm_external
5.1. If you update and repin your dependencies, your lock file will use the new format.
Usage
This version of rules_jvm_external
requires Bazel 6.5.0, Bazel 7.5.0 or Bazel 8.
This release requires Java 11 or above to run, both as the host JDK and the build and tool JDK.
Bzlmod
If you are using Bazel 7 or above, in your MODULE.bazel
file:
bazel_dep(name = "rules_jvm_external", version = "6.7")
To add dependencies, later in your MODULE.bazel
file:
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
artifacts = [
"org.seleniumhq.selenium:selenium-java:4.28.1",
],
repositories = [
"https://repo1.maven.org/maven2",
],
lock_file = "//:maven_install.json",
)
use_repo(maven, "maven")
Workspace-based builds
In your WORKSPACE
file, add:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "6.7"
RULES_JVM_EXTERNAL_SHA = "a1e351607f04fed296ba33c4977d3fe2a615ed50df7896676b67aac993c53c18"
http_archive(
name = "rules_jvm_external",
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
sha256 = RULES_JVM_EXTERNAL_SHA,
url = "https://github.com/bazel-contrib/rules_jvm_external/releases/download/%s/rules_jvm_external-%s.tar.gz" % (RULES_JVM_EXTERNAL_TAG, RULES_JVM_EXTERNAL_TAG)
)
load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
rules_jvm_external_deps()
load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")
rules_jvm_external_setup()
Then, later in your WORKSPACE
file, you can pull in dependencies from a maven repository:
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
artifacts = [
"org.seleniumhq.selenium:selenium-java:4.28.1",
],
repositories = [
"https://repo1.maven.org/maven2",
],
maven_install_json = "//:maven_install.json",
)
Using dependencies
In your BUILD.bazel
file, reference the targets directly:
java_library(
name = "example",
exports = [
"@maven//:org_seleniumhq_selenium_selenium_java",
],
)
What's Changed
- Fix docs generation for artifacts with compile only dependencies by @vinnybod in #1291
- Update HEAD to support Bazel 6 -> Bazel 8. by @jin in #1294
- Make multiple modules contributing to the same maven repo namespace warning less verbose and duplicated by @jin in #1295
- Bump robolectric-bazel to 4.14.1.2 by @utzcoz in #1301
- [auth][netrc] Empty account fallback to login by @stevebarrau in #1299
- Fix collection of Maven runtime deps by @fmeum in #1308
- Update protobuf to 29.3 (bzlmod only) by @joca-bt in #1314
- Add support for using Maven BOMs with Coursier by @protocol7 in #1306
- Give the coursier pin alias public visibility to match others by @erikkerber in #1319
- Assume third part of coordinates is a version number by @shs96c in #1311
New Contributors
- @stevebarrau made their first contribution in #1299
- @joca-bt made their first contribution in #1314
- @protocol7 made their first contribution in #1306
Full Changelog: 6.6...6.7