We're currently working on integrating AOT in the build plugins. At the moment, a typical output for processing the application at build time is as follows:
[INFO] --- spring-boot-maven-plugin:3.0.0-SNAPSHOT:aot-generate (aot-generate) @ demo-native-sample ---
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.0.0-SNAPSHOT)
2022-04-06 15:03:43.508 INFO 58801 --- [ main] c.e.d.DemoNativeSampleApplication : Starting DemoNativeSampleApplication using Java 17.0.2 on snicoll-a01.vmware.com with PID 58801 (/Users/snicoll/Downloads/demo-native-sample/target/classes started by snicoll in /Users/snicoll/Downloads/demo-native-sample)
2022-04-06 15:03:43.511 INFO 58801 --- [ main] c.e.d.DemoNativeSampleApplication : No active profile set, falling back to 1 default profile: "default"
[INFO]
[INFO] --- maven-jar-plugin:3.2.2:jar (default-jar) @ demo-native-sample ---
A log that state "Starting DemoNativeSampleApplication" can be confusing there as we're not really starting the application. Perhaps an alternative banner could help noticing that the application is being optimized.
There is a somewhat related concept in the core framework, see https://github.com/spring-projects/spring-framework/issues/28066. It would introduce three refresh modes: runtime (the regular, existing one), aot (not running the app but optimizing it), and runtime-aot (running the app with the optimizations). We could reuse this concept when preparing the context, such as the Environment, see https://github.com/spring-projects-experimental/spring-native/issues/1367 for an example.
On our side, we're looking at providing an extra property to SpringApplication. Perhaps an ApplicationType that would wrap WebApplicationType and this additional concept?
We'd like to be a bit more flexible than having to chose between all those concepts. Perhaps something like "Always use AOT" (and fail if the optimizations are not found), "Never use AOT" (don't use them, even if they are around), and "Auto" (use them if they are available, otherwise run the app as usual).
Comment From: snicoll
I am trying to prototype something around an ApplicationType that would wrap the WebApplicationType and a RunStrategy. The latter would be a way to determine how the application could be started.
See https://github.com/snicoll/spring-boot/commit/e61bba1a1455f56e89369cd1172446faadaec0c2
Comment From: snicoll
It turns out framework hasn't really done anything besides AotDetector that we already uses. It is possible to opt-in for that on the command line using the -Dspring.aot.enabled property.