我正在向jCenter添加一个库,因此我需要在项目的build.gradle文件中添加一些插件。但是,我得到了错误
Declaring custom 'clean' task when using the standard Gradle lifecycle plugins is not allowed.
我可以看到
task clean
块,当我删除它时,错误消失了。我以为这就是我要做的,但是以前做过重要的事情吗?如果我有时删除了插件,却忘记了重新添加clean
块,那么后果不堪设想?buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id "com.jfrog.bintray" version "1.7.3"
id "com.github.dcendents.android-maven" version "1.5"
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This和this不能令人满意地回答该问题。
最佳答案
您不应尝试覆盖默认的clean
任务,而应将其配置为删除其他内容,例如
clean {
delete rootProject.buildDir
}
但是,请首先检查这是否不是清理任务的默认行为。
另外,如果您希望能够单独执行特定的清理操作,则还可以定义一个单独的任务并添加一个依赖项,例如
task customClean(type: Delete) {
delete rootProject.buildDir
}
clean.dependsOn customClean
关于android-studio - 不允许在使用标准Gradle生命周期插件时声明自定义 'clean'任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43933459/