Gradle + Kotlin:子项目和插件问题

问题描述 投票:3回答:1

等级6.1.1

我一直在尝试使用Kotlin DSL转换项目的gradle文件,但到目前为止失败了。我所有的项目都是Java多项目构建。我关注了插件子项目的示例here

看起来像:

plugins {
    idea
    eclipse
}

subprojects {
    apply(plugin = "java")

    dependencies {
       implementation("com.google.guava:guava:28.1-jre")
       //...
    }
}

子项目中似乎不理解Java插件,并且所有“实现”行都得到了未解决的引用。

gradle gradle-kotlin-dsl
1个回答
0
投票

请参见文档https://docs.gradle.org/current/userguide/kotlin_dsl.html

类型安全访问器不适用于以下贡献的模型元素:

  • 通过apply(plugin =“ id”)方法应用的插件
  • ...
 implementation()

是这样的类型安全访问器。非类型安全的方式如下所示:

project(":domain") {
    apply(plugin = "java-library")
    dependencies {
        "api"("javax.measure:unit-api:1.0")
        "implementation"("tec.units:unit-ri:1.0.3")
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.