Add support for invoking AOT to the Gradle plugin

Closes gh-30527
This commit is contained in:
Andy Wilkinson
2022-04-06 12:01:33 +01:00
parent fd7bb53180
commit fcf45d5c22
16 changed files with 413 additions and 9 deletions

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.gradle.plugin;
import org.junit.jupiter.api.TestTemplate;
import org.springframework.boot.gradle.junit.GradleCompatibility;
import org.springframework.boot.testsupport.gradle.testkit.GradleBuild;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link NativeImagePluginAction}.
*
* @author Andy Wilkinson
*/
@GradleCompatibility(configurationCache = true)
class NativeImagePluginActionIntegrationTests {
GradleBuild gradleBuild;
@TestTemplate
void applyingNativeImagePluginAppliesAotPlugin() {
assertThat(this.gradleBuild.build("aotPluginApplied").getOutput())
.contains("org.springframework.boot.aot applied = true");
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.gradle.plugin;
import org.junit.jupiter.api.TestTemplate;
import org.springframework.boot.gradle.junit.GradleCompatibility;
import org.springframework.boot.testsupport.gradle.testkit.GradleBuild;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link SpringBootAotPlugin}.
*
* @author Andy Wilkinson
*/
@GradleCompatibility
class SpringBootAotPluginIntegrationTests {
GradleBuild gradleBuild;
@TestTemplate
void noGenerateAotSourcesTaskWithoutAotPluginApplied() {
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=generateAotSources").getOutput())
.contains("generateAotSources exists = false");
}
@TestTemplate
void applyingAotPluginCreatesGenerateAotSourcesTask() {
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=generateAotSources").getOutput())
.contains("generateAotSources exists = true");
}
}

View File

@@ -97,10 +97,10 @@ class BootRunIntegrationTests {
BuildResult result = this.gradleBuild.build("bootRun");
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_13)) {
assertThat(result.getOutput()).contains("1. -XX:TieredStopAtLevel=1");
assertThat(result.getOutput()).contains("-XX:TieredStopAtLevel=1");
}
else {
assertThat(result.getOutput()).contains("1. -Xverify:none").contains("2. -XX:TieredStopAtLevel=1");
assertThat(result.getOutput()).contains("-Xverify:none").contains("-XX:TieredStopAtLevel=1");
}
}
@@ -118,12 +118,12 @@ class BootRunIntegrationTests {
BuildResult result = this.gradleBuild.build("bootRun");
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_13)) {
assertThat(result.getOutput()).contains("1. -Dcom.bar=baz").contains("2. -Dcom.foo=bar")
.contains("3. -XX:TieredStopAtLevel=1");
assertThat(result.getOutput()).contains("-Dcom.bar=baz").contains("-Dcom.foo=bar")
.contains("-XX:TieredStopAtLevel=1");
}
else {
assertThat(result.getOutput()).contains("1. -Dcom.bar=baz").contains("2. -Dcom.foo=bar")
.contains("3. -Xverify:none").contains("4. -XX:TieredStopAtLevel=1");
assertThat(result.getOutput()).contains("-Dcom.bar=baz").contains("-Dcom.foo=bar").contains("-Xverify:none")
.contains("-XX:TieredStopAtLevel=1");
}
}