I want to run a project "clean" before the assembleRelease
task in Gradle.
How can I trigger the clean task basically before everything?
I want to run a project "clean" before the assembleRelease
task in Gradle.
How can I trigger the clean task basically before everything?
Use following code to execute the clean task first per each build variant
project.afterEvaluate {
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def capitalizedVariant = variant.name.capitalize()
def assembleVariantTask = project.tasks."assemble${capitalizedVariant}"
assembleVariantTask.dependsOn clean
}
}
}
In gradle you can use the
dependsOn
method.In this way:
In your case: