hey, anyone been porting gradle to use kotlin dsl?...
# android
hey, anyone been porting gradle to use kotlin dsl? I'm trying to but no matter what, I get
> The 'java' plugin has been applied, but it is not compatible with the Android plugins.
My guess is that
plugin includes java plugin which interferes with android plugin. Anyway, I have literally no idea how to repair it
Normally I could just delete this plugin but I can't since I'm using
file with dependencies
in module which causes the problem I only have
plugins, in addition I import dependencies from buildSrc module with
My guess is that
plugin includes java plugin which interferes with android plugin
Why do you apply kotlin-dsl plugin? this is need only if you want to develop own Gradle plugin and use Kotlin-DSL extensions
you shouldn’t use it for Android library/application module
You shouldn’t have such problem and kotlin-dsl shouldn’t cause any problems, maybe you could show some example
@gildor yeah sure will send these in a second, but one more thing: one of the dependencies needs
plugin, which seems that it doesn't exist, right? http://central.maven.org/maven2/org/jetbrains/kotlin/ or at least I can't find one
if I do include it (
apply plugin: 'kotlin-android'
), gradle tells me that it can't find it
Copy code
Extension with name 'android' does not exist. Currently registered extension names: [ext, sonarqube, defaultArtifacts, reporting, sourceSets, java, kotlin]
it looks somewhat like this https://codesandbox.io/s/pm6qvrkxm?fontsize=14&module=%2FprojectRoot%2Fbuild.gradle.kts&view=editor it's a work in progress so it may not be the preetiest code you see
You should use plugins DSL to use static accessors
Also official migration guide is very helpful and explains how to apply plugins to use static accessors https://guides.gradle.org/migrating-build-logic-from-groovy-to-kotlin/
@gildor sorry to bother you again, but there's one thing that's confusing to me when exactly should I use kotlin-dsl plugin?
When: if you need some Kotlin DSL helpers for you custom Gradle plugin Where: in buildSrc if you have custom plugin there or in standalone plugin's build.gradle
✔️ 1