Skip to content

Commit

Permalink
rules_java: Explicitly pass in the apparent repo name in local_jdk_re…
Browse files Browse the repository at this point in the history
…pository

Instead of trying to parse it out of the canonical repo name and splitting on `~`. We're looking to replace `~` with `+` due to bazelbuild/bazel#22865.

PiperOrigin-RevId: 651667204
Change-Id: Ia9beeee2f03510be2b0babe35550f151c96a9f8c
  • Loading branch information
Wyverald authored and copybara-github committed Jul 12, 2024
1 parent 6551a25 commit 000587f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions toolchains/local_java_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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)

0 comments on commit 000587f

Please sign in to comment.