From 5482f979debc466b4ca0c289bd8713cb363ea217 Mon Sep 17 00:00:00 2001 From: Kevin van den Broek Date: Thu, 25 Jan 2024 12:51:06 +0100 Subject: [PATCH] task: use Bazel provided Java Runtime JAVA_HOME is not set correctly, and can't be assumed to be present. Using the Bazel toolchain feature we can retrieve the correct location of a JRE. --- groovy/groovy.bzl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/groovy/groovy.bzl b/groovy/groovy.bzl index 91d9e77..cb67595 100644 --- a/groovy/groovy.bzl +++ b/groovy/groovy.bzl @@ -225,7 +225,8 @@ def _groovy_test_impl(ctx): classes = [path_to_class(src.path) for src in ctx.files.srcs] # Write a file that executes JUnit on the inferred classes - cmd = "$JAVA_HOME/bin/java %s -cp %s org.junit.runner.JUnitCore %s\n" % ( + cmd = "%s/bin/java %s -cp %s org.junit.runner.JUnitCore %s\n" % ( + ctx.attr._jdk[java_common.JavaRuntimeInfo].java_home, " ".join(ctx.attr.jvm_flags), ":".join([dep.short_path for dep in all_deps.to_list()]), " ".join(classes),