Fix skipping of processAot when there is no main source
See gh-32424
This commit is contained in:
@@ -101,10 +101,35 @@ class SpringBootAotPluginIntegrationTests {
|
||||
.isEqualTo(TaskOutcome.NO_SOURCE);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void processAotRunsWhenProjectHasMainSource() throws IOException {
|
||||
writeMainClass("org.springframework.boot", "AotProcessor");
|
||||
writeMainClass("com.example", "Main");
|
||||
assertThat(this.gradleBuild.build("processAot").task(":processAot").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void processTestAotIsSkippedWhenProjectHasNoTestSource() {
|
||||
assertThat(this.gradleBuild.build("processTestAot").task(":processTestAot").getOutcome())
|
||||
.isEqualTo(TaskOutcome.NO_SOURCE);
|
||||
}
|
||||
|
||||
private void writeMainClass(String packageName, String className) throws IOException {
|
||||
File java = new File(this.gradleBuild.getProjectDir(),
|
||||
"src/main/java/" + packageName.replace(".", "/") + "/" + className + ".java");
|
||||
java.getParentFile().mkdirs();
|
||||
Files.writeString(java.toPath(), """
|
||||
package %s;
|
||||
|
||||
public class %s {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
""".formatted(packageName, className));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user