-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugin): new GraalVm metadata Gradle task (#1743)
Create new Gradle task that automatically generates GraalVm reachability metadata for GraphQL Kotlin servers. Following metadata files are generated: * `native-image.properties` * `reflect-config.json` * `resource-config.json` Usage: ``` plugins { kotlin("jvm") version "1.7.21" application id("org.graalvm.buildtools.native") version "0.9.20" id("com.expediagroup.graphql") version $graphQLKotlinVersion } // other build configuration goes here graphql { graalVm { packages = listOf("com.example") } } ```
- Loading branch information
1 parent
ea6d503
commit f4ba9b4
Showing
21 changed files
with
631 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...in/kotlin/com/expediagroup/graphql/plugin/gradle/actions/GenerateGraalVmMetadataAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2023 Expedia, Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.expediagroup.graphql.plugin.gradle.actions | ||
|
||
import com.expediagroup.graphql.plugin.graalvm.generateGraalVmMetadata | ||
import com.expediagroup.graphql.plugin.gradle.parameters.GenerateGraalVmMetadataParameters | ||
import org.gradle.workers.WorkAction | ||
import java.io.File | ||
|
||
abstract class GenerateGraalVmMetadataAction : WorkAction<GenerateGraalVmMetadataParameters> { | ||
|
||
/** | ||
* Generate GraphQL GraalVM reachability metadata. | ||
*/ | ||
override fun execute() { | ||
val supportedPackages: List<String> = parameters.supportedPackages.get() | ||
val mainClassName: String? = parameters.mainClassName.orNull | ||
val targetDirectory: File = parameters.outputDirectory.get() | ||
|
||
generateGraalVmMetadata(targetDirectory = targetDirectory, supportedPackages = supportedPackages, mainClassName = mainClassName) | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...in/com/expediagroup/graphql/plugin/gradle/parameters/GenerateGraalVmMetadataParameters.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2023 Expedia, Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.expediagroup.graphql.plugin.gradle.parameters | ||
|
||
import org.gradle.api.provider.ListProperty | ||
import org.gradle.api.provider.Property | ||
import org.gradle.workers.WorkParameters | ||
import java.io.File | ||
|
||
/** | ||
* WorkParameters used for generating GraalVM reachability metadata for GraphQL schema. | ||
*/ | ||
interface GenerateGraalVmMetadataParameters : WorkParameters { | ||
/** List of supported packages that can contain GraphQL schema type definitions. */ | ||
val supportedPackages: ListProperty<String> | ||
/** Main application class name. */ | ||
val mainClassName: Property<String> | ||
/** Directory where to store generated reachability metadata. */ | ||
val outputDirectory: Property<File> | ||
} |
Oops, something went wrong.