I’ve been over the task docs (Ch6, Ch17, “Task” API), and I’m afraid I still don’t fully understand the syntax of basic task creation. Given the following build file:
task a << {
println "in a"
}
task b {
println "in b"
}
task (c, type: Copy) << {
println "in c"
}
task (d, type: Copy) {
println "in d"
}
I get the following output when running each task:
--> gradle a b c d
in b
in d
:a
in a
:b UP-TO-DATE
:c UP-TO-DATE
:d UP-TO-DATE
So in fact, defining task “b” and “d” in this manner makes it so they ALWAYS get run, no matter what task I put on the command-line. Conversely, task “c” never runs. I’m new to Groovy, and so perhaps there’s something about the syntax I’m not understanding, but this seems very confusing to me. Can someone clarify?
PS. I should add that I do understand that “<<” is an analog for doLast(), and that there are a few syntactical equivalents of my examples. What I do not understand is what’s happening under-the-hood in cases b, c, and d. Or why, if something there is incorrect, Gradle doesn’t warn me about it.