# How to understand task creation syntax?

**URL:** <https://discuss.gradle.org/t/how-to-understand-task-creation-syntax/4478>\
**Category:** Old Forum Archive\
**Created:** [June 12, 2012, 6:39am UTC](https://discuss.gradle.org/t/how-to-understand-task-creation-syntax/4478 "2012-06-12T06:39:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rtexas](https://avatars.discourse-cdn.com/v4/letter/r/71c47a/32.png) [@rtexas](https://discuss.gradle.org/u/rtexas)\
**Post date:** [June 12, 2012, 6:39am UTC](https://discuss.gradle.org/t/how-to-understand-task-creation-syntax/4478/1 "2012-06-12T06:39:00Z")

</div>

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:

```gradle
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
--> 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.

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [June 12, 2012, 9:47am UTC](https://discuss.gradle.org/t/how-to-understand-task-creation-syntax/4478/2 "2012-06-12T09:47:00Z")

</div>

The key concept you are missing is the distinction between configuration and execution.

There’s [a bit in the userguide]([http://gradle.org/docs/current/userguide/userguide\_single.html#sec:configuration\_and\_execution\_phase\_](http://gradle.org/docs/current/userguide/userguide_single.html#sec:configuration_and_execution_phase_) about this.

---

<div class="post-metadata">

**Author:** ![rtexas](https://avatars.discourse-cdn.com/v4/letter/r/71c47a/32.png) [@rtexas](https://discuss.gradle.org/u/rtexas)\
**Post date:** [June 12, 2012, 3:54pm UTC](https://discuss.gradle.org/t/how-to-understand-task-creation-syntax/4478/3 "2012-06-12T15:54:00Z")

</div>

You’re right, that was a bit I was unclear on. (Your link has a bad char in it, FYI, corrected link [here](http://gradle.org/docs/current/userguide/userguide_single.html#sec:configuration_and_execution_phase).) Thanks!

I was also a little shaky on the difference between setting properties and actions on a task. [This](http://www.practicalgradle.org/blog/2010/11/declaring-tasks/) blog post helped clear that up as well.
