这是我的build.gradle
buildscript {
ext {
...
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigationVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id "com.diffplug.gradle.spotless" version "3.26.0"
}
allprojects {
repositories {
google()
jcenter()
}
}
spotless {
kotlin {
target "**/*.kt"
ktlint(ktlintVersion).userData(['max_line_length' : '100'])
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}最初的编译是成功的,但是当引入spotless时,它导致了以下错误:
com.diffplug.gradle.spotless &&任务清除(类型: Delete){}错误:不能将任务“清除”添加为已存在的任务
所以,我想这两个部分是相互矛盾的,但我不知道具体的原因。
plugins {
id "com.diffplug.gradle.spotless" version "3.26.0"
}
//...
task clean(type: Delete) {
delete rootProject.buildDir
}发布于 2021-07-09 12:07:07
加上R.Desai的回答,
实际上,Gradle的BasePlugin只清理应用程序级别的构建目录。医生说
清除-删除构建目录及其中的所有内容,即Project.getBuildDir()项目属性指定的路径。
然而,解决办法是一样的。这个一尘不染的插件与您定义的“干净”任务是冲突的,因为它在引擎盖下具有相同的实现,这将清除项目级别的构建目录。这是他们的github回购“重复清洁任务#521”中的问题。
https://stackoverflow.com/questions/58990532
复制相似问题