From 000587f210b73e45e646a9e459166fc56853ff6a Mon Sep 17 00:00:00 2001 From: Googler Date: Fri, 12 Jul 2024 00:00:14 -0700 Subject: [PATCH] rules_java: Explicitly pass in the apparent repo name in local_jdk_repository Instead of trying to parse it out of the canonical repo name and splitting on `~`. We're looking to replace `~` with `+` due to https://github.com/bazelbuild/bazel/issues/22865. PiperOrigin-RevId: 651667204 Change-Id: Ia9beeee2f03510be2b0babe35550f151c96a9f8c --- toolchains/local_java_repository.bzl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/toolchains/local_java_repository.bzl b/toolchains/local_java_repository.bzl index 3f28baaf..ae5f82f8 100644 --- a/toolchains/local_java_repository.bzl +++ b/toolchains/local_java_repository.bzl @@ -178,8 +178,7 @@ def _local_java_repository_impl(repository_ctx): java_home = _determine_java_home(repository_ctx) - # When Bzlmod is enabled, the Java runtime name should be the last segment of the repository name. - local_java_runtime_name = repository_ctx.name.split("~")[-1] + local_java_runtime_name = repository_ctx.attr.runtime_name repository_ctx.file( "WORKSPACE", @@ -293,6 +292,7 @@ _local_java_repository_rule = repository_rule( configure = True, environ = ["JAVA_HOME"], attrs = { + "runtime_name": attr.string(), "build_file": attr.label(), "build_file_content": attr.string(), "java_home": attr.string(), @@ -332,4 +332,4 @@ def local_java_repository(name, java_home = "", version = "", build_file = None, version: optionally java version **kwargs: additional arguments for repository rule """ - _local_java_repository_rule(name = name, java_home = java_home, version = version, build_file = build_file, build_file_content = build_file_content, **kwargs) + _local_java_repository_rule(name = name, runtime_name = name, java_home = java_home, version = version, build_file = build_file, build_file_content = build_file_content, **kwargs)