我在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-stdlib
,kotlin-stdlib-jdk8
,kotlin-reflect
,kotlin-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/