我正在使用gradle 8为一个多模块项目编写构建脚本。0.2,在库中声明一些依赖关系。我的构建脚本如下所示
buildscript {
repositories {
gradlePluginPortal()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("gradle.plugin.com.github.johnrengelman:shadow:7.1.2")
}
}
plugins{
`kotlin-dsl`
}
group = "xxx"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_19
subprojects {
apply(plugin = "java")
apply(plugin = "checkstyle")
apply(plugin = "maven-publish")
apply(plugin = "com.github.johnrengelman.shadow")
// common deps + repos
repositories {
mavenCentral()
}
dependencies {
api(libs.jsr305)
testImplementation(libs.bundles.junit)
compileOnly(libs.lombok)
annotationProcessor(libs.lombok)
testCompileOnly(libs.lombok)
testAnnotationProcessor(libs.lombok)
}
java {
withSourcesJar()
}
tasks.named<Test>("test") {
useJUnitPlatform()
}
tasks.withType<JavaCompile>() {
options.encoding = "UTF-8"
}
tasks.withType<Javadoc>() {
options.encoding = "UTF-8"
}
}
我想在每个子项目中应用这些常见的依赖项,这些依赖项在库中定义。toml,我可以保证libs。toml的编写没有问题,但是我不能让它在子项目中工作
错误:
Extension with name 'libs' does not exist. Currently registered extension names: [ext, base, defaultArtifacts, sourceSets, reporting, javaToolchains, java, testing, checkstyle, publishing, shadow]
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Exception is:
org.gradle.api.UnknownDomainObjectException: Extension with name 'libs' does not exist. Currently registered extension names: [ext, base, defaultArtifacts, sourceSets, reporting, javaToolchains, java, testing, checkstyle, publishing, shadow]
1条答案
按热度按时间tzdcorbm1#
Gradle建议使用此:
会议插件