Skip to content

rules_jvm_external version 6 depends on rules_java #239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def contrib_rules_jvm_deps():
strip_prefix = "apple_rules_lint-0.3.2",
url = "https://github.com/apple/apple_rules_lint/archive/refs/tags/0.3.2.tar.gz",
)

maybe(
http_archive,
name = "io_bazel_stardoc",
Expand Down Expand Up @@ -40,6 +41,39 @@ def contrib_rules_jvm_deps():
urls = ["https://github.com/protocolbuffers/protobuf/archive/v{}.tar.gz".format(PROTOBUF_VERSION)],
)

# The `rules_java` major version is tied to the major version of Bazel that it supports,
# so this is different from the version in the MODULE file.
major_version = native.bazel_version.partition(".")[0]
if major_version == "5":
maybe(
http_archive,
name = "rules_java",
urls = [
"https://github.com/bazelbuild/rules_java/releases/download/5.5.1/rules_java-5.5.1.tar.gz",
],
sha256 = "73b88f34dc251bce7bc6c472eb386a6c2b312ed5b473c81fe46855c248f792e0",
)

elif major_version == "6":
maybe(
http_archive,
name = "rules_java",
urls = [
"https://github.com/bazelbuild/rules_java/releases/download/6.5.2/rules_java-6.5.2.tar.gz",
],
sha256 = "16bc94b1a3c64f2c36ceecddc9e09a643e80937076b97e934b96a8f715ed1eaa",
)
Comment on lines +57 to +65
Copy link
Contributor

@rdesgroppes rdesgroppes Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, doesn't work for me, with bazel 6.4.0:

ERROR: /path/to/external/remote_java_tools_linux/BUILD:27:23: @remote_java_tools_linux//:toolchain: missing value for mandatory attribute 'java_runtime' in 'java_toolchain' rule
ERROR: /path/to/external/remote_java_tools_linux/BUILD:32:23: @remote_java_tools_linux//:toolchain_hostjdk8: missing value for mandatory attribute 'java_runtime' in 'java_toolchain' rule
ERROR: /path/to/external/remote_java_tools_linux/BUILD:41:23: @remote_java_tools_linux//:legacy_toolchain: missing value for mandatory attribute 'java_runtime' in 'java_toolchain' rule
ERROR: /path/to/external/remote_java_tools_linux/BUILD:49:23: @remote_java_tools_linux//:legacy_toolchain_jvm8: missing value for mandatory attribute 'java_runtime' in 'java_toolchain' rule
ERROR: /path/to/external/remote_java_tools_linux/BUILD:56:23: @remote_java_tools_linux//:toolchain_vanilla: missing value for mandatory attribute 'java_runtime' in 'java_toolchain' rule
ERROR: /path/to/external/remote_java_tools_linux/BUILD:65:31: @remote_java_tools_linux//:toolchain_java8: missing value for mandatory attribute 'java_runtime' in 'java_toolchain' rule
ERROR: /path/to/external/remote_java_tools_linux/BUILD:72:31: @remote_java_tools_linux//:toolchain_java8_jvm8: missing value for mandatory attribute 'java_runtime' in 'java_toolchain' rule
ERROR: /path/to/external/remote_java_tools_linux/BUILD:65:31: @remote_java_tools_linux//:toolchain_java9: missing value for mandatory attribute 'java_runtime' in 'java_toolchain' rule
ERROR: /path/to/external/remote_java_tools_linux/BUILD:72:31: @remote_java_tools_linux//:toolchain_java9_jvm8: missing value for mandatory attribute 'java_runtime' in 'java_toolchain' rule
ERROR: /path/to/external/remote_java_tools_linux/BUILD:65:31: @remote_java_tools_linux//:toolchain_java10: missing value for mandatory attribute 'java_runtime' in 'java_toolchain' rule
ERROR: /path/to/external/remote_java_tools_linux/BUILD:72:31: @remote_java_tools_linux//:toolchain_java10_jvm8: missing value for mandatory attribute 'java_runtime' in 'java_toolchain' rule
ERROR: /path/to/external/remote_java_tools_linux/BUILD:65:31: @remote_java_tools_linux//:toolchain_java11: missing value for mandatory attribute 'java_runtime' in 'java_toolchain' rule
ERROR: /path/to/external/remote_java_tools_linux/BUILD:72:31: @remote_java_tools_linux//:toolchain_java11_jvm8: missing value for mandatory attribute 'java_runtime' in 'java_toolchain' rule
ERROR: /path/to/external/remote_java_tools_linux/BUILD:83:23: @remote_java_tools_linux//:toolchain_jdk_14: missing value for mandatory attribute 'java_runtime' in 'java_toolchain' rule
ERROR: /path/to/external/remote_java_tools_linux/BUILD:90:23: @remote_java_tools_linux//:toolchain_jdk_15: missing value for mandatory attribute 'java_runtime' in 'java_toolchain' rule
ERROR: /path/to/external/remote_java_tools_linux/BUILD:96:23: @remote_java_tools_linux//:prebuilt_toolchain: missing value for mandatory attribute 'java_runtime' in 'java_toolchain' rule
ERROR: /path/to/external/bazel_tools/tools/jdk/BUILD:171:14: Target '@remote_java_tools_linux//:prebuilt_singlejar' contains an error and its package is in error and referenced by '@bazel_tools//tools/jdk:prebuilt_singlejar_linux'

I seem to need rules_java 7.x.


else:
maybe(
http_archive,
name = "rules_java",
urls = [
"https://github.com/bazelbuild/rules_java/releases/download/7.3.2/rules_java-7.3.2.tar.gz",
],
sha256 = "3121a00588b1581bd7c1f9b550599629e5adcc11ba9c65f482bbd5cfe47fdf30",
)

maybe(
zip_repository,
name = "contrib_rules_jvm_deps",
Expand Down
9 changes: 9 additions & 0 deletions setup.bzl
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
load("@apple_rules_lint//lint:setup.bzl", "ruleset_lint_setup")
load("@contrib_rules_jvm_deps//:compat.bzl", "compat_repositories")
load("@contrib_rules_jvm_deps//:defs.bzl", "pinned_maven_install")
load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")

def contrib_rules_jvm_setup():
ruleset_lint_setup()

# When using bazel 5, we have undefined toolchains from rules_js. This should be fine to skip, since we only need
# it for the `JavaInfo` definition.
major_version = native.bazel_version.partition(".")[0]
if major_version != "5":
rules_java_dependencies()
rules_java_toolchains()

pinned_maven_install()
compat_repositories()