graphql-kotlin
graphql-kotlin copied to clipboard
Plugin fails with Kotlin MPP
Library Version 5.1.1
Describe the bug
Whenever Kotlin MPP is used instead of usual Kotlin, Expedia Gradle plugin fails to find compileKotlin
task
because in MPP you need compileKotlinJvm
Problem is in this line of code https://github.com/ExpediaGroup/graphql-kotlin/blob/2b9d673cbd623377f0c2ac3ae147658e86c6d3f6/plugins/graphql-kotlin-gradle-plugin/src/main/kotlin/com/expediagroup/graphql/plugin/gradle/GraphQLGradlePlugin.kt#L172
To Reproduce
plugins {
application
kotlin("multiplatform") version "1.5.31"
id("com.expediagroup.graphql") version "5.1.1"
}
kotlin {
jvm {
tasks {
graphql {
schema {
packages = listOf()
}
}
}
}
}
Expected behavior I should be able to build GraphQL with plugin for JVM in MPP projects
Workaround
- Add fake
compileKotlin
task - Set sourceSet and projectClasspath manually
plugins {
application
kotlin("multiplatform") version "1.5.31"
id("com.expediagroup.graphql") version "5.1.1"
}
kotlin {
jvm {
tasks.maybeCreate("compileKotlin").dependsOn(tasks.named("compileKotlinJvm"))
tasks.named<GraphQLGenerateSDLTask>("graphqlGenerateSDL") {
val srcSet = sourceSets.getByName("jvmMain").kotlin
source = srcSet.asFileTree
projectClasspath.setFrom(srcSet)
}
tasks {
graphql {
schema {
packages = listOf()
}
}
}
}
}