Update `SpringBootContextLoader` so that it now implements the
`AotContextLoader` interface. The `ContextLoaderHook` will abandon
at `contextLoaded` if the test class is being AOT processed.
This commit also introduces a new `AotApplicationContextInitializer`
which allows us to plug-in an alternative AOT application context
listener when the `SpringApplication` is running in test mode.
Closes gh-31965
Update `spring-boot-start-parent` with a new `nativeTest` profile. When
active, this profile will trigger AOT processing of test code and call
the native build tools 'test' goal.
Closes gh-32383
Add a new `useMainMethod` attribute to `SpringBootTest` which can be
used to determine how the test should run. The three available options
are:
- `ALWAYS`
- `NEVER`
- `WHEN_AVAILABLE`
The default is `WHEN_AVAILABLE` which will attempt to launch the test
using the `main` method if there is one.
The `SpringBootContextLoader` has been updated to use the new
`SpringApplicationHook` interface when the main method is being used.
Closes gh-22405
Create a new public SpringApplication Hook API based on the existing
`SpringApplicationRunListener` interface.
The previous package-private `SpringApplicationHooks` class has been
replaced with a public `SpringApplicationHook` interface which acts as
a factory that can create additional `SpringApplicationRunListener`
instances to hook in.
The boolean result from the previous `preRefresh` method has been
replaced with an `AbandonedRunException` which can be thrown from
the `SpringApplicationRunListener`.
Closes gh-32301
Update `EventPublishingRunListener` so that event listeners may add
additional listeners to the `SpringApplication` during early events.
Prior to this commit, the listeners were collected only once which
meant that if a listener for an `ApplicationStartingEvent` called
`application.addListener(...)`, it would be ignored.
Closes gh-32300