Add Gradle plugin support for processing test contexts ahead-of-time

Closes gh-32192
This commit is contained in:
Andy Wilkinson
2022-09-02 15:54:46 +01:00
parent 746ed84120
commit fd28f6d1d6
10 changed files with 323 additions and 64 deletions

View File

@@ -44,12 +44,24 @@ class SpringBootAotPluginIntegrationTests {
.contains("processAot exists = false");
}
@TestTemplate
void noProcessTestAotTaskWithoutAotPluginApplied() {
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=processTestAot").getOutput())
.contains("processTestAot exists = false");
}
@TestTemplate
void applyingAotPluginCreatesProcessAotTask() {
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=processAot").getOutput())
.contains("processAot exists = true");
}
@TestTemplate
void applyingAotPluginCreatesProcessTestAotTask() {
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=processTestAot").getOutput())
.contains("processTestAot exists = true");
}
@TestTemplate
void processAotHasLibraryResourcesOnItsClasspath() throws IOException {
File settings = new File(this.gradleBuild.getProjectDir(), "settings.gradle");
@@ -60,10 +72,26 @@ class SpringBootAotPluginIntegrationTests {
assertThat(this.gradleBuild.build("processAotClasspath").getOutput()).contains("library.jar");
}
@TestTemplate
void processTestAotHasLibraryResourcesOnItsClasspath() throws IOException {
File settings = new File(this.gradleBuild.getProjectDir(), "settings.gradle");
Files.write(settings.toPath(), List.of("include 'library'"));
File library = new File(this.gradleBuild.getProjectDir(), "library");
library.mkdirs();
Files.write(library.toPath().resolve("build.gradle"), List.of("plugins {", " id 'java-library'", "}"));
assertThat(this.gradleBuild.build("processTestAotClasspath").getOutput()).contains("library.jar");
}
@TestTemplate
void processAotHasTransitiveRuntimeDependenciesOnItsClasspath() {
String output = this.gradleBuild.build("processAotClasspath").getOutput();
assertThat(output).contains("org.jboss.logging" + File.separatorChar + "jboss-logging");
}
@TestTemplate
void processTestAotHasTransitiveRuntimeDependenciesOnItsClasspath() {
String output = this.gradleBuild.build("processTestAotClasspath").getOutput();
assertThat(output).contains("org.jboss.logging" + File.separatorChar + "jboss-logging");
}
}