我正在使用 buildSrc
多模块 Kotlin 项目中的模块到 manage dependency definitions and versions .该模块使用kotlin-dsl如build.gradle.kts所示:
plugins {
`kotlin-dsl`
}
替代声明:
plugins {
id("org.gradle.kotlin.kotlin-dsl") version "0.16.2"
}
我想使用相同的 Kotlin 版本来编译
buildSrc
模块以及应用程序模块内。我的第一次尝试是简单地添加 JVM 工件:plugins {
`kotlin-dsl`
kotlin("jvm") version "1.2.31"
}
然而,这会导致构建错误,已讨论 here :
Error resolving plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.2.31']
Plugin request for plugin already on the classpath must not include a version
有什么方便的方法只能定义一次整个项目使用的 Kotlin 版本?
有关的
最佳答案
Each Gradle release is meant to be used with a specific version of the
kotlin-dsl
plugin and compatibility between arbitrary Gradle releases andkotlin-dsl
plugin versions is not guaranteed.Using an unexpected version of the
kotlin-dsl
plugin in a build can cause hard to diagnose problems.Starting with Gradle 5.4, a warning is emitted whenever an unexpected version of the
kotlin-dsl
plugin is detected.
Paul Merlin @eskatos, 25.04.2019
因此,我已删除
version
:plugins {
`kotlin-dsl`
}
repositories {
mavenCentral()
}
关于gradle - 如何为 buildSrc 和应用程序模块定义 Kotlin 版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49522180/