Skip to content

Commit

Permalink
Merge pull request #1 from hvadehra/hvd_force_custom_java_toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
swarren12 authored Sep 18, 2024
2 parents 02d9613 + 54e26ee commit 4d196d7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@
common --experimental_downloader_config=downloader.cfg

common --enable_bzlmod

common --java_language_version=11
common --tool_java_language_version=11
common --java_runtime_version=custom_11
common --tool_java_runtime_version=custom_11

build --experimental_strict_java_deps=off
11 changes: 10 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
#
# Root BUILD
#
#
load("@rules_java//toolchains:default_java_toolchain.bzl", "default_java_toolchain", "bootclasspath")

default_java_toolchain(
name = "my_java11_toolchain",
java_runtime = "@jdk11//:jdk",
source_version = "11",
target_version = "11",
header_compiler_direct = ["@remote_java_tools//:TurbineDirect"],
)
8 changes: 6 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ module(
bazel_dep(name = "rules_java", version = "7.3.1", dev_dependency = True)
single_version_override(module_name = "rules_java", version = "7.3.1")

rules_java_ext = use_extension("@rules_java//java:extensions.bzl", "toolchains")
use_repo(rules_java_ext, "remote_java_tools")

custom_java = use_extension("//:java.bzl", "custom_java")
use_repo(custom_java, "jdk11")
use_repo(custom_java, "jdk11", "jdk11_toolchain_config_repo")

register_toolchains("@jdk11//:all")
register_toolchains("//:all")
register_toolchains("@jdk11_toolchain_config_repo//:all")

# Maven
### https://github.com/bazelbuild/rules_jvm_external
Expand Down
3 changes: 2 additions & 1 deletion java.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ load("@rules_java//toolchains:remote_java_repository.bzl", "remote_java_reposito
def _impl(modctx):
remote_java_repository(
name = "jdk11",
prefix = "custom",
version = "11",
urls = ["https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz"],
sha256 = "99be79935354f5c0df1ad293620ea36d13f48ec3ea870c838f20c504c9668b57",
strip_prefix = "jdk-11.0.2",
)

custom_java = module_extension(implementation = _impl)
custom_java = module_extension(implementation = _impl)

0 comments on commit 4d196d7

Please sign in to comment.