我正在将Gradle多模块构建从Groovy迁移到KotlinDSL,我想使用Gradle的静态类型版本目录。
// plugins declared in the settings.gradle.kts
subprojects {
apply {
plugin("groovy")
plugin("java-library")
plugin("ch.onstructive.gradle.release")
plugin("ch.onstructive.gradle.codestyle")
}
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.toVersion("17")
targetCompatibility = JavaVersion.toVersion("17")
}
dependencies {
val annotationProcessor by configurations
val implementation by configurations
annotationProcessor(libs.mapstruct.processor) // <-- cannot access the libs here
implementation(libs.mapstruct) // <-- cannot access the libs here
}
}
字符串
在我的gradle/libs.versions.toml
[versions]
mapstructVersion = "1.5.5.Final"
[libraries]
mapstruct-processor = { module = "org.mapstruct:mapstruct-processor", version.ref = "mapstructVersion" }
mapstruct = { module = "org.mapstruct:mapstruct", version.ref = "mapstructVersion" }
型
现在我得到以下错误
Build file 'build.gradle.kts' line: 54
Extension with name 'libs' does not exist. Currently registered extension names: [ext, base, defaultArtifacts, sourceSets, reporting, javaToolchains, java, groovyRuntime, testing, publishing, spotless, micronautSourceSetConfigurer, micronaut, eclipse, graalvmNative]
型
如何在subprojects
闭包的dependencies
闭包中使用版本目录?
1条答案
按热度按时间o2g1uqev1#
在这种情况下,可以使用
rootProject.libs
访问版本目录。字符串