Ensure that a test engine is available to AOT test processing

See gh-32192
pull/32235/head
Andy Wilkinson 2 years ago
parent cf84ae7ad8
commit 3dfe28c9f1

@ -86,7 +86,8 @@ public class SpringBootAotPlugin implements Plugin<Project> {
return sourceSets.create(newSourceSetName, (sourceSet) -> {
sourceSet.getJava().setSrcDirs(List.of("build/generated/" + newSourceSetName + "Sources"));
sourceSet.getResources().setSrcDirs(List.of("build/generated/" + newSourceSetName + "Resources"));
sourceSet.setCompileClasspath(sourceSet.getCompileClasspath().plus(existingSourceSet.getOutput()));
sourceSet.setCompileClasspath(sourceSet.getCompileClasspath().plus(existingSourceSet.getCompileClasspath())
.plus(existingSourceSet.getOutput()));
existingSourceSet.setRuntimeClasspath(existingSourceSet.getRuntimeClasspath().plus(sourceSet.getOutput()));
ConfigurationContainer configurations = project.getConfigurations();
Configuration implementation = configurations.getByName(sourceSet.getImplementationConfigurationName());
@ -151,7 +152,7 @@ public class SpringBootAotPlugin implements Plugin<Project> {
ProcessTestAot.class, (task) -> {
configureAotTask(project, aotTestSourceSet, task,
project.getLayout().getBuildDirectory().dir("generated/aotTestClasses"));
task.setTestClassesDirs(testSourceSet.getOutput().getClassesDirs());
task.setTestSourceSet(testSourceSet);
});
configureDependsOn(project, aotTestSourceSet, processTestAot);
}

@ -29,6 +29,7 @@ import org.gradle.api.file.FileCollection;
import org.gradle.api.tasks.CacheableTask;
import org.gradle.api.tasks.Classpath;
import org.gradle.api.tasks.JavaExec;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.TaskAction;
import org.springframework.boot.gradle.plugin.SpringBootPlugin;
@ -42,7 +43,7 @@ import org.springframework.boot.gradle.plugin.SpringBootPlugin;
@CacheableTask
public class ProcessTestAot extends AbstractAot {
private final FileCollection junitPlatformLauncher;
private final Configuration junitPlatformLauncher;
private FileCollection testClassesDirs;
@ -84,7 +85,14 @@ public class ProcessTestAot extends AbstractAot {
.collect(Collectors.joining(File.pathSeparator)));
args.addAll(processorArgs());
this.setArgs(args);
this.classpath(this.junitPlatformLauncher);
super.exec();
}
public void setTestSourceSet(SourceSet testSourceSet) {
setTestClassesDirs(testSourceSet.getOutput().getClassesDirs());
this.junitPlatformLauncher.extendsFrom(
getProject().getConfigurations().getByName(testSourceSet.getImplementationConfigurationName()));
}
}

Loading…
Cancel
Save