Groovy允许在ext
.
我想在 groovy 的额外属性中定义 Detekt 的版本。Detekt 是 Kotlin 语言的静态代码分析工具。
但是,当我按照以下方式进行操作时:
buildscript {
// testing, code-style, CI-tools
ext.detect_code_analysis = '1.0.0.RC6-3' //change to 1.0.0 when available
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:$gradle_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id "io.gitlab.arturbosch.detekt" version "$detect_code_analysis"
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
detekt {
version = "$detect_code_analysis"
profile("main") {
input = "$projectDir/app/src/main/java"
config = "$projectDir/detekt-config.yml"
filters = ".*test.*,.*/resources/.*,.*/tmp/.*"
}
}
它抱怨:
Error:(17, 0) startup failed:
build file '/Users[...]build.gradle': 17: argument list must be exactly 1 literal non empty string
See https://docs.gradle.org/4.1/userguide/plugins.html#sec:plugins_block for information on the plugins {} block
@ line 17, column 5.
id "io.gitlab.arturbosch.detekt" version "$detect_code_analysis"
^
1 error