Expose a system property when AOT processing is running
This commit exposes a "spring.aot.processing" system property when the AOT engine is running. This can be used by code that need to react differently when the application is being refreshed for AOT processing. Closes gh-29340
This commit is contained in:
@@ -27,13 +27,26 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Tests for {@link AbstractAotProcessor}, settings, and builder.
|
||||
* Tests for {@link AbstractAotProcessor}.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @author Stephane Nicoll
|
||||
* @since 6.0
|
||||
*/
|
||||
class AotProcessorTests {
|
||||
|
||||
@Test
|
||||
void springAotProcessingIsAvailableInDoProcess(@TempDir Path tempDir) {
|
||||
Settings settings = createTestSettings(tempDir);
|
||||
assertThat(new AbstractAotProcessor<String>(settings) {
|
||||
@Override
|
||||
protected String doProcess() {
|
||||
assertThat(System.getProperty("spring.aot.processing")).isEqualTo("true");
|
||||
return "Hello";
|
||||
}
|
||||
}.process()).isEqualTo("Hello");
|
||||
}
|
||||
|
||||
@Test
|
||||
void builderRejectsMissingSourceOutput() {
|
||||
assertThatIllegalArgumentException()
|
||||
@@ -123,4 +136,14 @@ class AotProcessorTests {
|
||||
assertThat(settings.getArtifactId()).isEqualTo("my-artifact");
|
||||
}
|
||||
|
||||
private static Settings createTestSettings(Path tempDir) {
|
||||
return Settings.builder()
|
||||
.sourceOutput(tempDir)
|
||||
.resourceOutput(tempDir)
|
||||
.classOutput(tempDir)
|
||||
.groupId("my-group")
|
||||
.artifactId("my-artifact")
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user