Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit681c70d

Browse files
authored
feat: use java toolchain when generating SDL (#2058)
### 📝 Descriptionwhen the toolchain used by kotlin/java compilation tasks generatesclassfiles with newer versions, running the task in-process (i.e. with`classLoaderIsolation`) results in a build failing withUnsupportedClassVersionError.switching to `processIsolation` and using (by default) the configuredjava toolchain should mitigate this### 🔗 Related Issuesnot raised (can raise an issue if required)
1 parent700f0ea commit681c70d

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

‎plugins/graphql-kotlin-gradle-plugin/src/main/kotlin/com/expediagroup/graphql/plugin/gradle/tasks/GraphQLGenerateSDLTask.kt‎

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,20 @@ package com.expediagroup.graphql.plugin.gradle.tasks
1919
importcom.expediagroup.graphql.plugin.gradle.actions.GenerateSDLAction
2020
importorg.gradle.api.file.ConfigurableFileCollection
2121
importorg.gradle.api.file.RegularFileProperty
22+
importorg.gradle.api.plugins.JavaPluginExtension
2223
importorg.gradle.api.provider.ListProperty
24+
importorg.gradle.api.provider.Property
2325
importorg.gradle.api.tasks.Classpath
2426
importorg.gradle.api.tasks.Input
27+
importorg.gradle.api.tasks.Nested
2528
importorg.gradle.api.tasks.Optional
2629
importorg.gradle.api.tasks.OutputFile
2730
importorg.gradle.api.tasks.SourceTask
2831
importorg.gradle.api.tasks.TaskAction
2932
importorg.gradle.api.tasks.options.Option
30-
importorg.gradle.workers.ClassLoaderWorkerSpec
33+
importorg.gradle.jvm.toolchain.JavaLauncher
34+
importorg.gradle.jvm.toolchain.JavaToolchainService
35+
importorg.gradle.workers.ProcessWorkerSpec
3136
importorg.gradle.workers.WorkQueue
3237
importorg.gradle.workers.WorkerExecutor
3338
importjavax.inject.Inject
@@ -57,14 +62,25 @@ abstract class GraphQLGenerateSDLTask : SourceTask() {
5762
@OutputFile
5863
val schemaFile:RegularFileProperty= project.objects.fileProperty()
5964

60-
@Inject
61-
abstractfungetWorkerExecutor():WorkerExecutor
65+
@get:Inject
66+
abstractval workerExecutor:WorkerExecutor
67+
68+
@get:Inject
69+
protectedabstractval javaToolchainService:JavaToolchainService
70+
71+
@get:Nested
72+
abstractval launcher:Property<JavaLauncher>
6273

6374
init {
6475
group="GraphQL"
6576
description="Generate GraphQL schema in SDL format."
6677

6778
schemaFile.convention(project.layout.buildDirectory.file("schema.graphql"))
79+
80+
@Suppress("LeakingThis")
81+
project.extensions.getByType(JavaPluginExtension::class.java).toolchain
82+
.let(javaToolchainService::launcherFor)
83+
.let(launcher::convention)
6884
}
6985

7086
@TaskAction
@@ -80,7 +96,12 @@ abstract class GraphQLGenerateSDLTask : SourceTask() {
8096
throwRuntimeException("failed to generate target schema directory =$targetDirectory")
8197
}
8298

83-
val workQueue:WorkQueue= getWorkerExecutor().classLoaderIsolation { workerSpec:ClassLoaderWorkerSpec->
99+
val workQueue:WorkQueue= workerExecutor.processIsolation { workerSpec:ProcessWorkerSpec->
100+
workerSpec.forkOptions {
101+
it.setExecutable(launcher.get().executablePath.asFile)
102+
}
103+
logger.debug("worker executable:\n${workerSpec.forkOptions.executable}")
104+
84105
val workerClasspath= pluginClasspath.plus(projectClasspath).plus(source.files)
85106
workerSpec.classpath.from(workerClasspath)
86107
logger.debug("worker classpath:\n${workerSpec.classpath.files.joinToString("\n")}")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp