Skip to content

Commit 7412932

Browse files
authored
Use runtime java home for third party audit task (#91412) (#91432)
We actually do indeed need to use the runtime Java for this task because depending on the target version, we may be loading classes for a later Java version. For example, if we use dependencies that are MR jars, then we in fact do load different classes depending on the runtime Java version. To test this properly then we need to use the target Java version to actually execute the task so it can both load the newer classes, and any classes from any newer APIs present in the later Java version.
1 parent 4ad150c commit 7412932

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/ThirdPartyAuditPrecommitPlugin.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.gradle.api.Task;
1717
import org.gradle.api.artifacts.Configuration;
1818
import org.gradle.api.tasks.TaskProvider;
19-
import org.gradle.internal.jvm.Jvm;
2019

2120
import java.nio.file.Path;
2221

@@ -61,7 +60,9 @@ public TaskProvider<? extends Task> createTask(Project project) {
6160
return dep.getGroup() != null && dep.getGroup().startsWith("org.elasticsearch") == false;
6261
}));
6362
t.dependsOn(resourcesTask);
64-
t.setJavaHome(Jvm.current().getJavaHome().getPath());
63+
if (BuildParams.getIsRuntimeJavaHomeSet()) {
64+
t.setJavaHome(BuildParams.getRuntimeJavaHome().getPath());
65+
}
6566
t.getTargetCompatibility().set(project.provider(BuildParams::getRuntimeJavaVersion));
6667
t.setSignatureFile(resourcesDir.resolve("forbidden/third-party-audit.txt").toFile());
6768
t.getJdkJarHellClasspath().from(jdkJarHellConfig);

0 commit comments

Comments
 (0)