bazel-contrib / bazel-contrib/rules_jvm_external
Using `java_export` rule with Bazel 7.0.0 requires declaration of `@@bazel_tools//tools/jdk:toolchain_type'` toolchain
- Dominant language
- Java
- Stars
- 373
- Forks
- 301
- Avg merge
- 6d 3h
- Merged PRs (30d)
- 5
Description
Given the following code in a `BUILD` file.
```
load("@rules_jvm_external//:defs.bzl", "java_export")
java_export(
name = "app-config-lib-export",
maven_coordinates = "com.bmuschko.app:config:1.0.0",
srcs = glob(["*.java"]),
deps = [
"@maven//:org_apache_commons_commons_configuration2"
],
runtime_deps = [
"@maven//:commons_beanutils_commons_beanutils"
]
)
```
Executing the command below produces an error message with Bazel 7.0.0.
```
$ bazelisk run --define "maven_repo=file://$HOME/.m2/repository" //src/main/java/com/bmuschko/app/config:app-config-lib-export
...
ERROR: /Users/bmuschko/dev/projects/getting-started-with-bazel/exercises/07-java-library-publish/solution/src/main/java/com/bmuschko/app/config/BUILD:14:12: in maven_project_jar rule //src/main/java/com/bmuschko/app/config:app-config-lib-export-project:
Traceback (most recent call last):
File "/private/var/tmp/_bazel_bmuschko/ed0d727382899f7e5d5e87a7e60a8415/external/rules_jvm_external~4.5/private/rules/maven_project_jar.bzl", line 65, column 32, in _maven_project_jar_impl
ijar = java_common.run_ijar(
File "/virtual_builtins_bzl/common/java/java_common.bzl", line 92, column 68, in _run_ijar
Error in _check_java_toolchain_is_declared_on_rule: Rule 'maven_project_jar' in '/Users/bmuschko/dev/projects/getting-started-with-bazel/exercises/07-java-library-publish/solution/src/main/java/com/bmuschko/app/config/BUILD:14:12' must declare '@@bazel_tools//tools/jdk:toolchain_type' toolchain in order to use java_common. See https://github.com/bazelbuild/bazel/issues/18970.
```
Contributor guide
Research direction
Reproduce the failure from the supplied BUILD snippet and Bazel 7.0.0 command. Start in private/rules/maven_project_jar.bzl at line 65 and compare the java_common call with Bazel's toolchain declaration requirement. Done means the java_export target runs without the reported toolchain error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100