gpt4 book ai didi

android - com.diffplug.gradle.spotless && 任务清理(类型 : Delete){} Error:Cannot add task 'clean' as a task with that name already exists

转载 作者:行者123 更新时间:2023-11-29 22:41:41 26 4
gpt4 key购买 nike

这是我的 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 && task clean(type: Delete){} Error:Cannot add task 'clean' as a task with that name already exists

所以,我猜这两部分是有冲突的,但我不知 Prop 体原因。

plugins {
id "com.diffplug.gradle.spotless" version "3.26.0"
}
//...
task clean(type: Delete) {
delete rootProject.buildDir
}

最佳答案

添加到 R.Desai 的回答中,

实际上 Gradle 的 BasePlugin 只清理应用级构建目录。医生说

clean — Delete Deletes the build directory and everything in it, i.e.the path specified by the Project.getBuildDir() project property.

Check the docs here for more info .

但是,解决方法是一样的。 spotless 插件与您定义的“干净”任务冲突,因为它在引擎盖下具有相同的实现,它会清理项目级构建目录。这是他们的 github repo 中的问题 "Duplicate clean task #521"

关于android - com.diffplug.gradle.spotless && 任务清理(类型 : Delete){} Error:Cannot add task 'clean' as a task with that name already exists,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58990532/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com