Skip to content

Commit e8edc5d

Browse files
zhangskzcopybara-github
authored andcommitted
Restore JDK8 compatibility in Bazel for libraries with dependencies from Maven (e.g. //java/util)
Adds lock_files to MODULE.bazel for maven dependencies to bypass rules_jvm_external's use of coursier to resolve dependency which is no longer JDK 8 compatible. ``` ERROR: An error occurred during the fetch of repository 'rules_jvm_external~~maven~protobuf_maven': Traceback (most recent call last): File "/workspace/_build/out/external/rules_jvm_external~/private/rules/coursier.bzl", line 993, column 38, in _coursier_fetch_impl dep_tree = make_coursier_dep_tree( File "/workspace/_build/out/external/rules_jvm_external~/private/rules/coursier.bzl", line 926, column 13, in make_coursier_dep_tree fail("Error while fetching artifact with coursier: " + exec_result.stderr) Error in fail: Error while fetching artifact with coursier: Error: Could not find or load main class @.workspace._build.out.external.rules_jvm_external~~maven~protobuf_maven.java_argsfile ERROR: <builtin>: fetching coursier_fetch rule //:rules_jvm_external~~maven~protobuf_maven: Traceback (most recent call last): File "/workspace/_build/out/external/rules_jvm_external~/private/rules/coursier.bzl", line 993, column 38, in _coursier_fetch_impl dep_tree = make_coursier_dep_tree( File "/workspace/_build/out/external/rules_jvm_external~/private/rules/coursier.bzl", line 926, column 13, in make_coursier_dep_tree fail("Error while fetching artifact with coursier: " + exec_result.stderr) Error in fail: Error while fetching artifact with coursier: Error: Could not find or load main class @.workspace._build.out.external.rules_jvm_external~~maven~protobuf_maven.java_argsfile ERROR: no such package '@@rules_jvm_external~~maven~protobuf_maven//': Error while fetching artifact with coursier: Error: Could not find or load main class @.workspace._build.out.external.rules_jvm_external~~maven~protobuf_maven.java_argsfile ERROR: /workspace/java/util/BUILD.bazel:9:13: //java/util:util depends on @@rules_jvm_external~~maven~protobuf_maven//:com_google_j2objc_j2objc_annotations in repository @@rules_jvm_external~~maven~protobuf_maven which failed to fetch. no such package '@@rules_jvm_external~~maven~protobuf_maven//': Error while fetching artifact with coursier: Error: Could not find or load main class @.workspace._build.out.external.rules_jvm_external~~maven~protobuf_maven.java_argsfile ERROR: Analysis of target '//java/util:util' failed; build aborted: Analysis failed ``` PiperOrigin-RevId: 739323125
1 parent 5680834 commit e8edc5d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

.github/workflows/test_java.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ jobs:
3434
# TODO: b/318555165 - enable the layering check. Currently it does
3535
# not work correctly with the toolchain in this Docker image.
3636
targets: //java/... //java/internal:java_version //compatibility/... --features=-layering_check
37-
# TODO: b/393604460 - enable bzlmod once coursier error is fixed.
38-
flags: --java_language_version=8 --noenable_bzlmod
37+
flags: --java_language_version=8
3938
- name: OpenJDK 11
4039
cache_key: '11'
4140
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:7.1.2-11-d9624f2aa83cba3eaf906f751d75b36aacb9aa82

MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ protobuf_maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
163163
protobuf_maven.install(
164164
name = "protobuf_maven",
165165
artifacts = PROTOBUF_MAVEN_ARTIFACTS,
166+
lock_file = "//:maven_install.json",
166167
repositories = [
167168
"https://repo1.maven.org/maven2",
168169
"https://repo.maven.apache.org/maven2",
@@ -184,6 +185,7 @@ protobuf_maven_dev.install(
184185
"biz.aQute.bnd:biz.aQute.bndlib:6.4.0",
185186
"info.picocli:picocli:4.6.3",
186187
],
188+
lock_file = "//:maven_dev_install.json",
187189
repositories = [
188190
"https://repo1.maven.org/maven2",
189191
"https://repo.maven.apache.org/maven2",

0 commit comments

Comments
 (0)