gpt4 book ai didi

gradle - 如何为 buildSrc 和应用程序模块定义 Kotlin 版本?

转载 作者:行者123 更新时间:2023-12-04 15:39:37 25 4
gpt4 key购买 nike

我正在使用 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 版本?

有关的
  • Gradle Kotlin DSL: Define Kotlin version in unique place
  • Kotlin versions and the Gradle Kotlin DSL
  • Sample project: Multi-kotlin-project-with-buildSrc
  • 最佳答案

    Each Gradle release is meant to be used with a specific version of the kotlin-dsl plugin and compatibility between arbitrary Gradle releases and kotlin-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/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com