is it possible for Gradle to execute a task before calling
gradle build
Something like precompile
. Someone please help. Is something like this possible and how?
You can do it in this way:
task build << {
println 'build'
}
task preBuild << {
println 'do it before build'
}
build.dependsOn preBuild
Thanks to that task preBuild
will be automatically called before build
task.
If you want to run preBuild
in configuration phase (previous example run preBuild
in execution
phase) you can do it in this way:
task build << {
println 'build'
}
build.doFirst {
println 'do it before build'
}
More about gradle build lifecycle can be read here http://www.gradle.org/docs/current/userguide/build_lifecycle.html.