Skip to content
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

Register Java 8 runtimes with Bzlmod #181

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ register_toolchains(

# Declare all remote jdk toolchain config repos
JDKS = {
# Must match JDK repos defined in remote_jdk8_repos()
"8": [
"linux",
"linux_aarch64",
"linux_s390x",
"macos",
"macos_aarch64",
"windows",
],
# Must match JDK repos defined in remote_jdk11_repos()
"11": [
"linux",
Expand Down Expand Up @@ -70,7 +79,7 @@ JDKS = {
],
}

REMOTE_JDK_REPOS = [("remotejdk" + version + "_" + platform) for version in JDKS for platform in JDKS[version]]
REMOTE_JDK_REPOS = [(("remote_jdk" if version == "8" else "remotejdk") + version + "_" + platform) for version in JDKS for platform in JDKS[version]]

[use_repo(
toolchains,
Expand Down
11 changes: 10 additions & 1 deletion java/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@
# limitations under the License.
"""Module extensions for rules_java."""

load("//java:repositories.bzl", "java_tools_repos", "local_jdk_repo", "remote_jdk11_repos", "remote_jdk17_repos", "remote_jdk21_repos")
load(
"//java:repositories.bzl",
"java_tools_repos",
"local_jdk_repo",
"remote_jdk11_repos",
"remote_jdk17_repos",
"remote_jdk21_repos",
"remote_jdk8_repos",
)

def _toolchains_impl(_ctx):
java_tools_repos()
local_jdk_repo()
remote_jdk8_repos()
remote_jdk11_repos()
remote_jdk17_repos()
remote_jdk21_repos()
Expand Down
17 changes: 3 additions & 14 deletions java/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,6 @@ def remote_jdk8_repos(name = ""):
],
version = "8",
)
REMOTE_JDK8_REPOS = [
"remote_jdk8_linux_aarch64",
"remote_jdk8_linux_s390x",
"remote_jdk8_linux",
"remote_jdk8_macos_aarch64",
"remote_jdk8_macos",
"remote_jdk8_windows",
]
for name in REMOTE_JDK8_REPOS:
native.register_toolchains(
"@" + name + "_toolchain_config_repo//:toolchain",
"@" + name + "_toolchain_config_repo//:bootstrap_runtime_toolchain",
)

def remote_jdk11_repos():
"""Imports OpenJDK 11 repositories."""
Expand Down Expand Up @@ -581,6 +568,8 @@ def rules_java_toolchains(name = "toolchains"):
name: The name of this macro (not used)
"""
JDKS = {
# Must match JDK repos defined in remote_jdk8_repos()
"8": ["linux", "linux_aarch64", "linux_s390x", "macos", "macos_aarch64", "windows"],
# Must match JDK repos defined in remote_jdk11_repos()
"11": ["linux", "linux_aarch64", "linux_ppc64le", "linux_s390x", "macos", "macos_aarch64", "win", "win_arm64"],
# Must match JDK repos defined in remote_jdk17_repos()
Expand All @@ -589,7 +578,7 @@ def rules_java_toolchains(name = "toolchains"):
"21": ["linux", "linux_aarch64", "macos", "macos_aarch64", "win"],
}

REMOTE_JDK_REPOS = [("remotejdk" + version + "_" + platform) for version in JDKS for platform in JDKS[version]]
REMOTE_JDK_REPOS = [(("remote_jdk" if version == "8" else "remotejdk") + version + "_" + platform) for version in JDKS for platform in JDKS[version]]

native.register_toolchains(
"//toolchains:all",
Expand Down