Declaring a custom "clean" task when using standard Gradle lifecycle plugins is prohibited

I am adding the library to jCenter, so for this I need to add some plugins to the build.gradle file of the project. However, I am getting the error

Declaring a custom "clean" task when using standard Gradle lifecycle plugins is not allowed.

I see the block task clean

and when I delete it the error goes away. I guess that's all I need to do, but has it done anything important before? If I ever remove plugins and forget to add a block clean

, what are the dire consequences in the store?

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 and this , this has not been satisfactorily answered.

+29


source to share


9 replies


You should not try to override the default job clean

, but instead tweak it to remove additional files such as

clean {
    delete rootProject.buildDir
}

      

But first check if this is the default clean task behavior.



Alternatively, if you want to be able to do a separate clean action individually, you can also define a separate task and add a dependency like

task customClean(type: Delete) {
    delete rootProject.buildDir
}
clean.dependsOn customClean

      

+28


source


Remove these lines from your code.



task clean(type: Delete) {
    delete rootProject.buildDir
}

      

+6


source


tools> kotlin> configure in the project you need to select Android Gradle not Gradle

This worked for me

+3


source


I had this same problem, unfortunately for me I put it task clean

in the wrong place. I had this:

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }

    tasks.withType(JavaCompile) {
        sourceCompatibility = "1.8"
        targetCompatibility = "1.8"
    }


    task clean(type: Delete) {
        delete rootProject.buildDir
    }
}

      

It should be as follows:

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }

    tasks.withType(JavaCompile) {
        sourceCompatibility = "1.8"
        targetCompatibility = "1.8"
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

      

+2


source


In the above code:

allprojects {
repositories {
    google()
    jcenter()
    mavenCentral()
}

tasks.withType(JavaCompile) {
    sourceCompatibility = "1.8"
    targetCompatibility = "1.8"
}


task clean(type: Delete) {
    delete rootProject.buildDir
}
}

      

replace task clean

with task delete

then it will work:

allprojects {
repositories {
    google()
    jcenter()
    mavenCentral()
}

tasks.withType(JavaCompile) {
    sourceCompatibility = "1.8"
    targetCompatibility = "1.8"
}


task delete(type: Delete) {
    delete rootProject.buildDir'
}
}

      

+2


source


enter code hereallprojects {
repositories {
    google()
    jcenter()
    maven {
        url 'https://maven.google.com'
    }
}

      

}

task clean(type: Delete) {
    delete rootProject.buildDir
}

      

if you've added maven to your build.gradle then check all brackets. The code should be the same as above. This should fix the problem. It is possible that the parentheses are in different places.

0


source


After so much research, I found that we just need to comment out the clean task line in bulid.gradle (Project) like below:

//    task clean(type: Delete) {
//        delete rootProject.buildDir
//    }][1][enter image description here][1]

      

See image for clue

0


source


I am making a project for a birthday song named .... using text to speech .... so how can I concatenate a string from an mp3 song ??

0


source


6m Ok, I am getting an error in Gradle that it cannot clear the root project file.

: 25 AM Gradle Sync Failed: Declaring a custom "clean" task when using standard Gradle lifecycle plugins is not allowed.

error code info-ide.actionsShowFilePathAction Exit Code 1

Clean triggers nom run clean dependsOn "npmInstall"

In Gradle doc 4.7, the project in the directory where the build is performed is also configured, but only when Gradle is running without any tasks. This way, tasks by default behave correctly when projects are configured on demand.

Config on Demand Gradle 4.6 Android Plugin for Gradle 3.01 or 3.1.0 with Gradle Gradle Properties File org.gradleconfigureondemand = false

So what I did is to comment the task clean and now I am getting an assembly of these words,

I think what happened is that this script works if you created and modified the project. When you upload a project, you didn't create it the first time. Therefore there is no root project path to clean up as it has not been built yet. This results in a crash. When you comment this the first time, you won't get an error.

Here is the code. // Top level build file where you can add configuration options common to all subprojects / modules.

`buildscript {ext.kotlin_version = '1.2.41

     ext.support_version = '26.1.0'

repositories {
    google()
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: β€˜kotlin’

allprojects {
repositories {
google()
jcenter()
}
}

/*
task clean(type: Delete) {
delete rootProject.buildDir

} */

'

      

-1


source







All Articles