Kotlin DSL is not able to build projects that depend on each other & are also standalone. I have created a reduced test case to reproduce the issue.
Error resolving plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.2.41']
Plugin request for plugin already on the classpath must not include a version
I have two projects:
kotlin_poc defines a main method that calls Bash.execute from xctest_parserobject Main {
@Throws(Exception::class)
@JvmStatic
fun main(args: Array<String>) {
println(Bash.execute("hi"))
}
}
package xctest
object Bash {
fun execute(cmd: String): String {
return "ok"
}
}
I expect to build kotlin_poc which depends on xctest_parser and also be able to build xctest_parser standalone
$ ./gradlew build
FAILURE: Build failed with an exception.
* Where:
Build file '/gradle_classpath_bug/cloud_testing/xctest_parser/build.gradle.kts' line: 19
* What went wrong:
Error resolving plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.2.41']
> Plugin request for plugin already on the classpath must not include a version
If I comment out the version kotlin("jvm") version Versions.KOTLIN in xctest_parser/build.gradle.kts, then kotlin_poc/build.gradle.kts builds. However that breaks building xctest_parser independently. To make xctest_parser build, I have to add back version kotlin("jvm") version Versions.KOTLIN in xctest_parser/build.gradle.kts.
$ git clone https://github.com/bootstraponline/gradle_classpath_bug.git
$ cd cloud_testing/kotlin_poc
$ ./gradlew build
Please use composite builds (includeBuild) if you want to combine builds. Using include means the other project becomes a subproject and can by definition not be standalone at the same time.
Most helpful comment
Please use composite builds (
includeBuild) if you want to combine builds. Usingincludemeans the other project becomes a subproject and can by definition not be standalone at the same time.