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.6.1 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.8")
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.8"
RULES_JVM_EXTERNAL_SHA = "704a0197e4e966f96993260418f2542568198490456c21814f647ae7091f56f2"
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
- Implement different scope behavior for generated pom files by @vinnybod in #1336
- Add support to
outdated
for BOMs by @cheister in #1341 - Fix a fatal error when printing verbose logs when dependencies contain exclusions by @vinnybod in #1342
- Use Bazel's JDK to run coursier by @cheister in #1323
- Fix the docs to use the correct tag name by @chrismgrayftsinc in #1339
- Pass boms during (unpinned) coursier fetch by @joca-bt in #1350
- Use
copy_file
instead of agenrule
to link things in the generated workspaces by @shs96c in #1361 - Flip
fail_if_repin_required
toTrue
by default by @shs96c in #1371 - Avoid spurious warnings about poorly formatted artifact coordinates by @shs96c in #1374
- Prepare for 6.8 release by @sumeetgajjar in #1380
- Add support for gradle resolver by @smocherla-brex in #1357
- Update maven-metadata.xml when publishing locally by @AustinSchuh in #1369
- Ensure root module artifacts and boms take precedence with warnings by @shs96c in #1373
- Allow root module's override tags to take precedence over the overridees from transitive deps. by @sumeetgajjar in #1381
- Modify maven_export to allow exporting zip archives by @AustinSchuh in #1368
- Allow package exclusions and inclusions in javadocs by @vinnybod in #1293
- Allow coursier artifacts to have empty versions provided by BOMs and don't include them in outdated by @cheister in #1390
- [bzlmod] Allow suppressing warning about multiple contributing modules. by @mkosiba in #1393
- Remove dep on android ndk. by @jin in #1305
- Add support for reading artifacts from a file by @shs96c in #1400
New Contributors
- @sumeetgajjar made their first contribution in #1380
- @AustinSchuh made their first contribution in #1369
- @mkosiba made their first contribution in #1393
Full Changelog: 6.7...6.8