Fix classpath roots of AOT test processing

This was regressed in 6175c4210d so that
each class on the classpath was passed in as a "root". This commit
corrects this so that only the roots are passed to the AOT test
processor.

See gh-32424
This commit is contained in:
Andy Wilkinson 2022-09-22 12:29:25 +01:00
parent d7537bf66a
commit 7c7c34cda1
3 changed files with 14 additions and 7 deletions

View File

@ -138,7 +138,7 @@ public class SpringBootAotPlugin implements Plugin<Project> {
task.getClassesOutput().set(generatedClasses);
task.getGroupId().set(project.provider(() -> String.valueOf(project.getGroup())));
task.getArtifactId().set(project.provider(() -> project.getName()));
task.setInputClasses(inputSourceSet.getOutput().getClassesDirs());
task.setClasspathRoots(inputSourceSet.getOutput().getClassesDirs());
}
private void configureDependsOn(Project project, SourceSet aotSourceSet,

View File

@ -21,6 +21,7 @@ import java.util.List;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.FileTree;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.IgnoreEmptyDirectories;
import org.gradle.api.tasks.Input;
@ -52,7 +53,7 @@ public abstract class AbstractAot extends JavaExec {
private final Property<String> artifactId;
private FileCollection inputClasses;
private FileCollection classpathRoots;
protected AbstractAot() {
this.sourcesDir = getProject().getObjects().directoryProperty();
@ -87,16 +88,22 @@ public abstract class AbstractAot extends JavaExec {
return this.classesDir;
}
@InputFiles
@PathSensitive(PathSensitivity.RELATIVE)
public final FileCollection getClasspathRoots() {
return this.classpathRoots;
}
@InputFiles
@SkipWhenEmpty
@IgnoreEmptyDirectories
@PathSensitive(PathSensitivity.RELATIVE)
public final FileCollection getInputClasses() {
return this.inputClasses.getAsFileTree();
final FileTree getInputClasses() {
return this.classpathRoots.getAsFileTree();
}
public void setInputClasses(FileCollection inputClasses) {
this.inputClasses = inputClasses;
public void setClasspathRoots(FileCollection classpathRoots) {
this.classpathRoots = classpathRoots;
}
List<String> processorArgs() {

View File

@ -69,7 +69,7 @@ public class ProcessTestAot extends AbstractAot {
@TaskAction
public void exec() {
List<String> args = new ArrayList<>();
args.add(this.getInputClasses().getFiles().stream().filter(File::exists).map(File::getAbsolutePath)
args.add(this.getClasspathRoots().getFiles().stream().filter(File::exists).map(File::getAbsolutePath)
.collect(Collectors.joining(File.pathSeparator)));
args.addAll(processorArgs());
this.setArgs(args);