Helper library for writing Gradle plugins in Kotlin?


#1

Hi all,

I’ve managed to start translating some Gradle plugins from Groovy + Java to Kotlin. In doing this, I wanted some helper extension functions etc. to make my life easier. I found some in “org.gradle:gradle-script-kotlin:0.8.0” but I’m not sure I’m supposed to be applying that as a compile-time dependency of a Gradle plugin. I say that because, when I do, I have to add resolutionStrategy { force 'org.codehaus.groovy:groovy-all:2.4.10' } to all configurations of my plugin, because the gradle-script-kotlin plugin depends on a different version of Groovy from Gradle itself. I also get the following warnings.

w: Some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version of the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath or use '-Xskip-runtime-version-check' to suppress this warning w: C:\Users\hugr\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-compiler-embeddable\1.1.0\782efe747ea43b08fa3d2c3184e83173934a7acb\kotlin-compiler-embeddable-1.1.0.jar: Library has Kotlin runtime bundled into it

I am able to build and run my plugin, which uses methods like public inline fun <reified T : org.gradle.api.Task> org.gradle.api.Project.task(name: kotlin.String, noinline configuration: T.() -> kotlin.Unit): T { /* compiled code */ } from ProjectExtensions.kt but the warnings suggest I should be doing something else.

I looked into “gradle.plugin.org.gradle.kotlin:gradle-kotlin-dsl-plugins:0.10.9” but that’s not the right thing at all – that’s for being able to write your Gradle scripts in Kotlin, as far as I can see.

Is there something else I should be using? Am I using “org.gradle:gradle-script-kotlin” incorrectly?

Thanks for any suggestions …