-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: GraalVM native image support for Spring server #1769
Conversation
Changes to enable GraalVM native image support for `graphql-kotlin-spring-server`.
@@ -34,7 +34,7 @@ class GenerateGraalVmMetadataMojo : AbstractSourceMojo() { | |||
override lateinit var outputDirectory: File | |||
|
|||
override fun generate() { | |||
val metadataDirectory = File(outputDirectory, "META-INF/native-image/${project.groupId}/${project.name}") | |||
val metadataDirectory = File(outputDirectory, "META-INF/native-image/${project.groupId}/${project.name}/graphql") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GraalVM plugin looks for reachability metadata under any META-INF/native-image
subdirectories. Per GraalVM documentation they suggest to generate reachability metadata under <groupId>/<artifactId>
subdirectory to avoid collisions. Adding explicit graphql
subdirectory to avoid collision with SpringBoot plugin generating metadata under the same directory.
@@ -29,13 +30,21 @@ data class GraphQLConfigurationProperties( | |||
val packages: List<String>, | |||
/** Boolean flag indicating whether to print the schema after generator creates it */ | |||
val printSchema: Boolean = false, | |||
@NestedConfigurationProperty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required extra metadata to generate GraalVM native image (docs)
@@ -1,5 +1,10 @@ | |||
import java.util.Properties | |||
|
|||
@Suppress("DSL_SCOPE_VIOLATION") // TODO: remove once KTIJ-19369 / Gradle#22797 is fixed | |||
plugins { | |||
alias(libs.plugins.graalvm.native) apply false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GraalVM native plugin dynamically generates some "helper" methods so we need to ensure they are generated just once for whole composite project, otherwise build blows up with classpath issues.
Apply same change to Gradle (use `graphql` subdirectory) as was done for Maven. SpringBoot JAR complains about duplicate resources otherwise...
📝 Description
Changes to enable GraalVM native image support for
graphql-kotlin-spring-server
.🔗 Related Issues