26
26
import org .gradle .api .attributes .Usage ;
27
27
import org .gradle .api .attributes .java .TargetJvmVersion ;
28
28
import org .gradle .api .plugins .JavaPlugin ;
29
+ import org .gradle .api .plugins .jvm .JvmTestSuite ;
29
30
import org .gradle .api .tasks .testing .Test ;
31
+ import org .gradle .testing .base .TestingExtension ;
30
32
31
33
import java .util .Collections ;
32
34
@@ -47,6 +49,8 @@ public class RuntimeHintsAgentPlugin implements Plugin<Project> {
47
49
public void apply (Project project ) {
48
50
49
51
project .getPlugins ().withType (JavaPlugin .class , javaPlugin -> {
52
+ TestingExtension testing = project .getExtensions ().getByType (TestingExtension .class );
53
+ JvmTestSuite jvmTestSuite = (JvmTestSuite ) testing .getSuites ().getByName ("test" );
50
54
RuntimeHintsAgentExtension agentExtension = createRuntimeHintsAgentExtension (project );
51
55
Test agentTest = project .getTasks ().create (RUNTIMEHINTS_TEST_TASK , Test .class , test -> {
52
56
test .useJUnitPlatform (options -> {
@@ -55,6 +59,8 @@ public void apply(Project project) {
55
59
test .include ("**/*Tests.class" , "**/*Test.class" );
56
60
test .systemProperty ("java.awt.headless" , "true" );
57
61
test .systemProperty ("org.graalvm.nativeimage.imagecode" , "runtime" );
62
+ test .setTestClassesDirs (jvmTestSuite .getSources ().getOutput ().getClassesDirs ());
63
+ test .setClasspath (jvmTestSuite .getSources ().getRuntimeClasspath ());
58
64
test .getJvmArgumentProviders ().add (createRuntimeHintsAgentArgumentProvider (project , agentExtension ));
59
65
});
60
66
project .getTasks ().getByName ("check" , task -> task .dependsOn (agentTest ));
0 commit comments