I would like to configure Kotlions’s KotlinCompile
class, but in a lazy way, only when this plugin is used by the project. So I have an only compile-time dependency on Kotlin plugin.
And then I’m trying do this:
project.tasks.matching { it::class.simpleName?.contains("KotlinCompile") ?: false}.all {
...
}
And even
project.plugins.matching { it::class.simpleName?.contains("KotlinAndroidPlugin") ?: false }.all {
project.tasks.matching { it::class.simpleName?.contains("KotlinCompile") ?: false}.all {
...
}
}
So I’m sure that Kotlin plugin was initialized in the time when my callback is called.
If there is no Kotlin it is not called.
But still, inside of inner lambda, I got java.lang.NoClassDefFoundError
every time I tried to touch KotlinCompile class
I don’t understand how Gradle can add KotlinCompile
task without having it loaded by classloader.
Until now we was using old good apply way, which has one big advantage, that all classes of all plugins are on classpath in the time of plugin initialisation.
So I was able do just this
project.tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
....
}
And it works great. But now with plugins {}
this way doesn’t works.