Reputation: 73
I'm Android Developer.
How to run a task(like methodA) after clean the project?
In other words,I want to execute a method after clean my Android project
Thanks!
Upvotes: 1
Views: 2653
Reputation: 3813
task removeSomeStuff(type: Delete) {
//some stuff after clean
delete file('projectFilesBackup')
}
task clean(type: Delete) {
delete rootProject.buildDir
finalizedBy removeSomeStuff
}
Upvotes: 1
Reputation: 17444
In build.gradle:
def methodA() {
print "Method A"
}
tasks['clean'] << {
methodA()
}
The <<
operator is a shorthand to add a "do last" closure to a task. Alternatively:
tasks['clean'].doLast({
methodA()
})
Upvotes: 2