add AOT & native image support#638
Conversation
| * Runtime hints for Spring Data OpenSearch core functionality. | ||
| * Registers Spring Data callbacks and entity mapping classes. | ||
| * | ||
| * @since 3.0.4 |
There was a problem hiding this comment.
added the @since since i presume that this is still used here, even though most versions are from when it was copied away from spring-data-elasticsearch and thus the @since annotations IMHO don't make too much sense?
| alias(pluginLibs.plugins.spotless) | ||
| alias(pluginLibs.plugins.editorconfig) | ||
| id("java-conventions") | ||
| id("org.graalvm.buildtools.native") version "0.11.5" |
There was a problem hiding this comment.
v1.0.0 is already released on their github repo but not yet available on the gradle repos. by the time this PR is ready we can probably directly go with v1.0.0.
open question: should this version be defined in the central settings.gradle.kts as well?
There was a problem hiding this comment.
open question: should this version be defined in the central settings.gradle.kts as well?
We need it in one place for now, right? May not be worth settings.gradle.kts
| graalvmNative { | ||
| binaries { | ||
| named("main") { | ||
| sharedLibrary.set(false) |
There was a problem hiding this comment.
the standard examples for the Gradle+Spring Boot+GraalVM combination don't usually include this block, but without setting sharedLibrary.set(false) i never got a binary - i just got a library and thus couldn't run nativeRun.
i'm happy to remove this if anyone figures out what's causing this (this is my first time working with GraalVM)
this registers the necessary hints for [Ahead-of-Time Processing] to support both AOT and [GraalVM Native Image] usage. it also modifies one example application so that it can - optionally - be run as a native image to show that it works. this is also used in CI to test that it still builds. on its own this will fail since by using AOT we automatically also pull in the AOT hints registered in `spring-data-elasticsearch` which in turn currently unconditionally registers hints for the Elasticsearch Client (ELC) which we however exclude as a transient dependency. thus a PR has been raised to make this optional: spring-projects/spring-data-elasticsearch#3267 this will have to be merged & released first for this PR to work. i have however verified things locally (though admittedly on the previous major release since i only had GraalVM 21 at hand and SB 4.x requires GraalVM 25). `ElasticsearchClientAutoConfiguration` also needs to be excluded in the `MarketplaceApplication` since otherwise two `JacksonJsonpMapper` beans will be present and the application will fail to start in the `processAot` phase. resolves opensearch-project#411 [Ahead-of-Time Processing]: https://docs.spring.io/spring-boot/reference/packaging/aot.html [GraalVM Native Image]: https://docs.spring.io/spring-boot/reference/packaging/native-image/index.html Signed-off-by: Ralph Ursprung <Ralph.Ursprung@avaloq.com>
5493b12 to
04f978a
Compare
| * Runtime hints for OpenSearch Java client library. | ||
| * `opensearch-java` does not provide its own hints since this is Spring-specific. | ||
| * | ||
| * @since 3.0.4 |
There was a problem hiding this comment.
To my knowledge, there won't be any bugports to Spring Data Elasticsearch 6.0.x (only bugfixes), if the change on its side lands (🙏 ), we will be able to use in in 6.1.0 only
| * @since 3.0.4 | |
| * @since 3.1.0 |
| /** | ||
| * Runtime hints for Spring Data OpenSearch repository implementations. | ||
| * | ||
| * @since 3.0.4 |
There was a problem hiding this comment.
| * @since 3.0.4 | |
| * @since 3.1.0 |
this registers the necessary hints for Ahead-of-Time Processing to support both AOT and GraalVM Native Image usage. it also modifies one example application so that it can - optionally - be run as a native image to show that it works. this is also used in CI to test that it still builds.
on its own this will fail since by using AOT we automatically also pull in the AOT hints registered in
spring-data-elasticsearchwhich in turn currently unconditionally registers hints for the Elasticsearch Client (ELC) which we however exclude as a transient dependency. thus a PR has been raised to make this optional: spring-projects/spring-data-elasticsearch#3267 this will have to be merged & released first for this PR to work.i have however verified things locally (though admittedly on the previous major release since i only had GraalVM 21 at hand and SB 4.x requires GraalVM 25).
Issues Resolved
resolves #411
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.