android - com.diffplug.gradle.spotless && task clean(type: Delete){} Error:Cannot add task 'clean' as a task with the name already exists
问题描述
这是我的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
所以,我猜这两个部分是冲突的,但我不知道具体原因。
plugins {
id "com.diffplug.gradle.spotless" version "3.26.0"
}
//...
task clean(type: Delete) {
delete rootProject.buildDir
}
解决方案
您在项目级别定义了此任务build.gradle
(如您的评论中发布的那样):
task clean(type: Delete) {
delete rootProject.buildDir
}
Android StudioGradle wrapper
已经clean
定义了一个任务,所以不需要重新定义它。只需从项目级build.gradle
文件中删除该任务即可。
推荐阅读
- python - 理解函数中的“return data_mine['one'] = 1”
- wso2ei - 当datamapper mediator抛出一些错误时EI无法提供服务
- sql - Sqlite3:“删除......哪里不在......”的正确魔力是什么?
- google-apps-script - 将 .XLSX 转换为 Google Sheet 并移动转换后的文件的脚本
- sql - 从表 A 的列中提取文本并插入表 B
- c# - 未定义的预处理器变量“$(var.WixInstall.TargetPath)”。WixInstaller D:work\Extractor\WixInstaller\Product.wxs
- android - 我可以防止 onFling() 和 onDown() 都触发吗?
- time-series - 在 Tsay 的平均代码中将虚拟变量放在 GARCH 中的哪里并获得输出?
- ruby-on-rails - 出于测试目的,尝试从一个 actionmailer 方法返回所有已发送电子邮件的数组
- opencv - 如何获得干净的视差图和干净的深度图