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
diff --git a/toolchains/local_java_repository.bzl b/toolchains/local_java_repository.bzl index 3f28baa..ae5f82f 100644 --- a/toolchains/local_java_repository.bzl +++ b/toolchains/local_java_repository.bzl
@@ -178,8 +178,7 @@ 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 @@ 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 @@ 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)