Fix arguments passed to AOT processing in Gradle plugin

See gh-30527
pull/30890/head
Andy Wilkinson 3 years ago
parent 8cf63a28b8
commit 293a3c9ec1

@ -22,9 +22,11 @@ import org.gradle.api.Plugin;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.ConfigurationContainer; import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.file.Directory;
import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginExtension; import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.plugins.PluginContainer; import org.gradle.api.plugins.PluginContainer;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.TaskProvider; import org.gradle.api.tasks.TaskProvider;
@ -82,10 +84,14 @@ public class SpringBootAotPlugin implements Plugin<Project> {
.named(SpringBootPlugin.RESOLVE_MAIN_CLASS_NAME_TASK_NAME, ResolveMainClassName.class); .named(SpringBootPlugin.RESOLVE_MAIN_CLASS_NAME_TASK_NAME, ResolveMainClassName.class);
TaskProvider<GenerateAotSources> generateAotSources = project.getTasks() TaskProvider<GenerateAotSources> generateAotSources = project.getTasks()
.register(GENERATE_AOT_SOURCES_TASK_NAME, GenerateAotSources.class, (task) -> { .register(GENERATE_AOT_SOURCES_TASK_NAME, GenerateAotSources.class, (task) -> {
Provider<Directory> generatedClasses = project.getLayout().getBuildDirectory()
.dir(GENERATE_AOT_SOURCES_TASK_NAME);
aotSourceSet.getOutput().dir(generatedClasses);
task.getApplicationClass().set(resolveMainClassName.flatMap((thing) -> thing.readMainClassName())); task.getApplicationClass().set(resolveMainClassName.flatMap((thing) -> thing.readMainClassName()));
task.setClasspath(aotSourceSet.getCompileClasspath()); task.setClasspath(aotSourceSet.getCompileClasspath());
task.getSourcesDir().set(aotSourceSet.getJava().getSrcDirs().iterator().next()); task.getSourcesDir().set(aotSourceSet.getJava().getSrcDirs().iterator().next());
task.getResourcesDir().set(aotSourceSet.getResources().getSrcDirs().iterator().next()); task.getResourcesDir().set(aotSourceSet.getResources().getSrcDirs().iterator().next());
task.getClassesDir().set(generatedClasses);
task.getGroupId().set(project.provider(() -> String.valueOf(project.getGroup()))); task.getGroupId().set(project.provider(() -> String.valueOf(project.getGroup())));
task.getArtifactId().set(project.provider(() -> project.getName())); task.getArtifactId().set(project.provider(() -> project.getName()));
}); });

@ -96,6 +96,8 @@ public class GenerateAotSources extends JavaExec {
args.add(this.sourcesDir.getAsFile().get().getAbsolutePath()); args.add(this.sourcesDir.getAsFile().get().getAbsolutePath());
args.add(this.resourcesDir.getAsFile().get().getAbsolutePath()); args.add(this.resourcesDir.getAsFile().get().getAbsolutePath());
args.add(this.classesDir.getAsFile().get().getAbsolutePath()); args.add(this.classesDir.getAsFile().get().getAbsolutePath());
args.add(this.groupId.get());
args.add(this.artifactId.get());
args.addAll(super.getArgs()); args.addAll(super.getArgs());
this.setArgs(args); this.setArgs(args);
super.exec(); super.exec();

Loading…
Cancel
Save