gradle - kotlin-bom库做什么?

标签 gradle kotlin

我在Gradle下创建了一个新的Kotlin项目。默认情况下,它将依赖关系设置为Kotlin-library项目。而且我想知道 kotlin-bom lib的作用是什么?

dependencies {
    // Align versions of all Kotlin components
    implementation(platform("org.jetbrains.kotlin:kotlin-bom"))

    // Use the Kotlin JDK 8 standard library.
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

    // Use the Kotlin test library.
    testImplementation("org.jetbrains.kotlin:kotlin-test")

    // Use the Kotlin JUnit integration.
    testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
}

最佳答案

kotlin-bom工件是仅依赖项的POM,它将所有Kotlin SDK库与相同版本对齐。

有关示例,请参见the POM content for version 1.3.72。它使用POM的dependencyManagement部分来依赖所有Kotlin SDK工件的相同版本,例如kotlin-stdlibkotlin-stdlib-jdk8kotlin-reflectkotlin-test等。

BOM的描述

Software bill of materials (BOMs) don’t specify a dependency on a module or file, but instead are a list of version constraints for other components. They define what is called a platform, which is basically a list of components with specific versions that are known to play well together and/or form a useful unit of functionality. It’s worth mentioning that not all of the dependencies listed in the BOM actually have to be included in your projects — it’s basically a way of saying “If you use any of these modules, use this version”.
-- A deep dive into an initial Kotlin build.gradle.kts

关于gradle - kotlin-bom库做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59790315/

相关文章:

android - 检查EditText是否为空kotlin android

java - org.apache.http.impl.io.DefaultHttpRequestWriterFactory 中的 NoSuchFieldError 实例

java - 尾随部分不允许有 Gradle 内容

java - 我们如何在 Maven 中为主要和测试 java 代码集拥有不同的 PMD 规则集?

java - 过滤机会枚举并根据随机机会选择一个

android - 如何修复 Kotlin JobCancellationException?

gradle - gradle doLast在 Action 之前执行

java - Gradle:不要让传递依赖项在项目源中使用

android - invoke 和 init kotlin 之间的区别

Android:如何检查用户是否有 Activity 订阅