rules_java
rules_java copied to clipboard
How to use `remote_java_repository` with a JDK release where Java home is nested?
I'm trying to use remote_java_repository
with GraalVM releases on MacOS.
When extracting the package the layout is of the form:
└── Contents
├── Home
│ ├── bin
│ │ ├── java
│ │ ├── javac
There are no top level symlinks into the nested bin
directory as can be seen in the Zulu JDK releases that remote_java_repository
is normally used with.
Would it be possible to make this rule configurable so that the path to the Java home inside the extracted distribution can be customized?
On closer inspection I'm not sure if there is something that is causing the files not to be unpacked at all, I can find the tar file in the cache and the path where it was meant to be unpacked but the directory is empty. (hence I run into errors with bin/javac not being found etc)
Any tips on debugging what is going wrong here?
@josephglanville have you tried strip_prefix
?
## Setup: Java
load("@rules_java//toolchains:remote_java_repository.bzl", "remote_java_repository")
GRAALVM_SDK_VERSION = "23.1.0-dev-20230803_2234"
JAVA_VERSION = "21"
JAVA_TOOLCHAIN = "@graalvm//:all"
GRAALVM_DOWNLOAD_PREFIX = "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download"
GRAALVM_PATH_PREFIX = "graalvm-community-openjdk-21+30.1"
remote_java_repository(
name = "graalvm",
sha256 = "01e1934581a84467a882be2ca64a735e296e3b7e6f470effff076730fb516e3b",
strip_prefix = "%s/Contents/Home" % GRAALVM_PATH_PREFIX,
target_compatible_with = [
"@platforms//cpu:aarch64",
"@platforms//os:macos",
],
urls = [
"%s/%s/graalvm-community-java%s-darwin-aarch64-dev.tar.gz" % (
GRAALVM_DOWNLOAD_PREFIX,
GRAALVM_SDK_VERSION,
JAVA_VERSION,
),
],
version = JAVA_VERSION,
)
register_toolchains(
JAVA_TOOLCHAIN,
)
@josephglanville i encountered some trouble with this too, so i released rules_graalvm
over the weekend, which supports use of GraalVM as a Java toolchain.
@josephglanville did https://github.com/bazelbuild/rules_java/issues/102#issuecomment-1676674836 fix this for you?
@hvadehra I haven't been back to this project to try out the fix unfortunately.
Alright, feel free to ping here if this comes up again.