Skip to content

Commit 2b503ee

Browse files
committed
Add AOT-generated classes as a dependency
Previously, the AOT-generated classes were added directly to the compile classpath of the AOT compilation task. This didn't work perfectly in IntelliJ IDEA, leaving the generated classes in the runtime scope and causing compilation problems where the AOT-generated source tried to reference those classes. This commit updates the plugin to add the AOT-generated classes as a dependency to the AOT source set's implementation configuration. This makes the classes available during compilation by the source set's Java compilation task while also makeing IntelliJ IDEA aware of their presence on the compile classpath. Closes gh-32395
1 parent 0476b5d commit 2b503ee

File tree

1 file changed

+1
-3
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin

1 file changed

+1
-3
lines changed

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootAotPlugin.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.gradle.api.tasks.SourceSet;
3434
import org.gradle.api.tasks.SourceSetContainer;
3535
import org.gradle.api.tasks.TaskProvider;
36-
import org.gradle.api.tasks.compile.JavaCompile;
3736

3837
import org.springframework.boot.gradle.tasks.aot.AbstractAot;
3938
import org.springframework.boot.gradle.tasks.aot.ProcessAot;
@@ -123,8 +122,7 @@ private void registerProcessAotTask(Project project, SourceSet aotSourceSet) {
123122
task.getApplicationClass()
124123
.set(resolveMainClassName.flatMap(ResolveMainClassName::readMainClassName));
125124
});
126-
project.getTasks().named(aotSourceSet.getCompileJavaTaskName(), JavaCompile.class).configure(
127-
(javaCompile) -> javaCompile.setClasspath(javaCompile.getClasspath().plus(project.files(aotClasses))));
125+
project.getDependencies().add(aotSourceSet.getImplementationConfigurationName(), project.files(aotClasses));
128126
aotSourceSet.getOutput().dir(aotClasses);
129127
configureDependsOn(project, aotSourceSet, processAot);
130128
}

0 commit comments

Comments
 (0)