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?
In gradle you can use the dependsOn
method.
B.dependsOn A
In this way:
In your case:
assembleRelease.dependsOn clean
Could not get unknown property 'assembleRelease' for project ':app' of type org.gradle.api.Project.
–
Prize tasks { }
block. Which buildscript depends on which project you want to configure. –
Rapine Adding to this, what I needed to do was have this in the
android {
afterEvaluate {
assemble(*your task here*)debug clean
}
and now it works great
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
}
}
}
© 2022 - 2024 — McMap. All rights reserved.