When use root build.gradle.kts file and inside buildscript > dependencies variables from buildSrc build failed. When use without buildSrc or when not use kts file but juts Groovy build.gradle variables works.
Build project without failure
Fail on
Script compilation errors:
Line 18: classpath(Config.BuildPlugins.androidPlugin)
^ Unresolved reference: Config
Demo project with reproducible bug: https://github.com/mtrakal/kotlinDslbug
Diff file from working to not workign project (rename file and change lines): https://github.com/mtrakal/kotlinDslbug/commit/09a5db46a10ed0c6d30942e3eede8b1787d7721a
See on demo project
Maybe related with second issue with default namespace: https://github.com/gradle/kotlin-dsl/issues/1088
Gradle 5.1.1 with Gradle DSL, still not working as expected.
CONFIGURE FAILED in 4s
Script compilation errors:
Line 33: classpath("com.android.tools.build:gradle:${Config.Versions.gradleBuildTools}")
^ Unresolved reference: Config
Line 34: classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Config.Versions.kotlinVersion}")
^ Unresolved reference: Config
Line 35: classpath("com.google.android.gms:oss-licenses-plugin:${Config.Versions.PlayServices.ossLicensesPlugin}")
^ Unresolved reference: Config
Line 36: classpath("com.google.gms:google-services:${Config.Versions.googleServicesVersion}")
^ Unresolved reference: Config
classpath("com.android.tools.build:gradle:${Config.Versions.gradleBuildTools}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Config.Versions.kotlinVersion}")
classpath("com.google.android.gms:oss-licenses-plugin:${Config.Versions.PlayServices.ossLicensesPlugin}")
classpath("com.google.gms:google-services:${Config.Versions.googleServicesVersion}")
same as: https://github.com/gradle/kotlin-dsl/issues/939
https://github.com/gradle/kotlin-dsl/issues/1319
same for plugins block:
plugins {
id("com.gradle.build-scan") version cz.bs.Config.Versions.buildScanVersion
}
vs
import cz.bs.Config;
plugins {
id("com.gradle.build-scan") version Config.Versions.buildScanVersion
}
Any progress here? Is there a workaround something like that?
@luxmeter workaround is on my previous comment... 馃檭. Use fully qualified package name
Hi, thanks for the quick reply. you mean to full qualify the class? What exactly do you mean? To use groovy instead?
The comment with the workaround is not obvious to me :)
Fully qualified in this context means, that you can't import the package and use only the class name. So for the above example, it must be cz.bs.Config.BuildPlugins.androidPlugin instead of importing the cz.bs package and use only Config.BuildPlugins.androidPlugin for the variable name.
See also the documentation/tuorial of Java for package names: https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html
Closing as duplicate of https://github.com/gradle/kotlin-dsl/issues/939
Most helpful comment
same as: https://github.com/gradle/kotlin-dsl/issues/939
https://github.com/gradle/kotlin-dsl/issues/1319
same for plugins block:
vs