diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootAotPlugin.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootAotPlugin.java index e384e0bf5d..4b752a29d1 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootAotPlugin.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootAotPlugin.java @@ -22,9 +22,11 @@ import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.ConfigurationContainer; +import org.gradle.api.file.Directory; import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPluginExtension; import org.gradle.api.plugins.PluginContainer; +import org.gradle.api.provider.Provider; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.TaskProvider; @@ -82,10 +84,14 @@ public class SpringBootAotPlugin implements Plugin { .named(SpringBootPlugin.RESOLVE_MAIN_CLASS_NAME_TASK_NAME, ResolveMainClassName.class); TaskProvider generateAotSources = project.getTasks() .register(GENERATE_AOT_SOURCES_TASK_NAME, GenerateAotSources.class, (task) -> { + Provider generatedClasses = project.getLayout().getBuildDirectory() + .dir(GENERATE_AOT_SOURCES_TASK_NAME); + aotSourceSet.getOutput().dir(generatedClasses); task.getApplicationClass().set(resolveMainClassName.flatMap((thing) -> thing.readMainClassName())); task.setClasspath(aotSourceSet.getCompileClasspath()); task.getSourcesDir().set(aotSourceSet.getJava().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.getArtifactId().set(project.provider(() -> project.getName())); }); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/aot/GenerateAotSources.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/aot/GenerateAotSources.java index 92d599f9b7..1b059ddc84 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/aot/GenerateAotSources.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/aot/GenerateAotSources.java @@ -96,6 +96,8 @@ public class GenerateAotSources extends JavaExec { args.add(this.sourcesDir.getAsFile().get().getAbsolutePath()); args.add(this.resourcesDir.getAsFile().get().getAbsolutePath()); args.add(this.classesDir.getAsFile().get().getAbsolutePath()); + args.add(this.groupId.get()); + args.add(this.artifactId.get()); args.addAll(super.getArgs()); this.setArgs(args); super.exec();