rules_jvm_external
rules_jvm_external copied to clipboard
bzlmod: Consider documenting the need to add --enable_bzlmod to examples
Hello,
I've been playing a bit with Bazel 6, bzlmod and rules_jvm_external over the last two days, and one thing that took me a lot of time to figure out was that it wasn't just enough to put the load() instructions in the BUILD.bazel
files, e.g.:
WORKSPACE.bzlmod
bazel_dep(name = "rules_java", version = "5.3.5")
bazel_dep(name = "rules_jvm_external", version = "4.5")
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
artifacts = [
"some.group.id:some.artifact.id:1.2.34",
],
)
use_repo(
maven,
"maven",
)
BUILD.bazel
load("@rules_jvm_external//:defs.bzl", "artifact")
java_binary(
name = "app",
srcs = glob(['src/main/java/**/*.java']),
deps = [
artifact("some.group.id:some.artifact.id"),
],
)
This would just complain that it couldn't find the repository rules_jvm_external.
I also had to put this into my .bazelrc
file:
common --enable_bzlmod
Now I don't yet understand why that's necessary, but as it took a lot of digging for me, and basically tearing down an existing example to get it working, I'm sure that others would encounter the same issue if they were to test out Bazel 6 and bzlmod.
I think the broader issue is that bzlmod usage isn't documented at all yet.