我在一个多模块项目中设置了 Detekt。下面是我的根级别build.gradle
tasks.register("detektAll", Detekt) {
description = "Custom Detekt build for all modules"
parallel = true
setSource(file(projectDir))
config.setFrom(files("$rootDir/detekt.yml"))
jvmTarget = "1.8"
classpath.setFrom(project.configurations.getByName("detekt"))
include("**/*.kt")
exclude("**/build/**")
reports {
html {
enabled = true
destination = file("$rootDir/build/reports/detekt-results.html")
}
xml.enabled = false
txt.enabled = false
}
}
现在我正在考虑设置我遵循的自定义规则
这就是我build.gradle
的customdetekt
模块的样子
apply plugin: 'kotlin'
repositories {
mavenCentral()
}
dependencies {
compileOnly "io.gitlab.arturbosch.detekt:detekt-api:1.17.1"
testImplementation "junit:junit:4.13.2"
testImplementation "org.assertj:assertj-core:3.20.2"
testImplementation "io.gitlab.arturbosch.detekt:detekt-api:1.17.1"
testImplementation "io.gitlab.arturbosch.detekt:detekt-test:1.17.1"
}
现在,当我使用以下方法在主模块中连接自定义规则模块时:
detektPlugins project(path: ':customdetekt', configuration: 'default')
我收到一个错误:
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method detektPlugins() for arguments [DefaultProjectDependency{dependencyProject='project ':customdetekt''
请帮忙