When the Spring Boot Gradle plugin builds a fat jar and the Native
Build Tools Gradle plugin is applied to the build, any configuration
files from the GraalVM reachability metadata repository that match
project dependencies are copied to a `META-INF/native-image`
directory in the fat jar.
Closes gh-32408
Previously, when using Tomcat, its web app class loader was the thread
context class loader when H2ConsoleAutoConfiguration triggered
initialization of Hikari's pool. This was the case because it's done
in the bean method of a ServletRegistrationBean. Such Servlet-related
beans are intentionally created with Tomcat's web app classloader as
the TCCL. This arrangement results in the pool's threads using
Tomcat's web app class loader as their TCCL which is not desirable.
One consequence of this was that Tomcat could log a warning at
shutdown about the thread being left running when it will, in fact,
be stopped as part of the context being closed.
This commit updates H2ConsoleAutoConfiguration to set the TCCL to its
own ClassLoader while the DataSource information is being logged.
Closes gh-32382
Previously, the AOT-generated classes were added directly to the
compile classpath of the AOT compilation task. This didn't work
perfectly in IntelliJ IDEA, leaving the generated classes in the
runtime scope and causing compilation problems where the
AOT-generated source tried to reference those classes.
This commit updates the plugin to add the AOT-generated classes as
a dependency to the AOT source set's implementation configuration.
This makes the classes available during compilation by the source
set's Java compilation task while also makeing IntelliJ IDEA aware
of their presence on the compile classpath.
Closes gh-32395
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