Kotlin-dsl-samples: Kotlin DSL breaks building individual Kotlin projects

Created on 1 Jun 2018  路  1Comment  路  Source: gradle/kotlin-dsl-samples


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

Expected Behavior



I have two projects:

  • kotlin_poc defines a main method that calls Bash.execute from xctest_parser

Main.kt

object Main {

    @Throws(Exception::class)
    @JvmStatic
    fun main(args: Array<String>) {
      println(Bash.execute("hi"))
    }
}

Bash.kt

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

Current Behavior

$ ./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

Context

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.

Steps to Reproduce (for bugs)

$ git clone https://github.com/bootstraponline/gradle_classpath_bug.git
$ cd cloud_testing/kotlin_poc
$ ./gradlew build

Your Environment

  • macOS 10.13.4
  • gradle 4.7
question

Most helpful comment

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.

>All comments

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.

Was this page helpful?
0 / 5 - 0 ratings