# What is 'task' syntactically in 'task sometask(map) { ... }'?

**URL:** <https://discuss.gradle.org/t/what-is-task-syntactically-in-task-sometask-map/6416>\
**Category:** Old Forum Archive\
**Created:** [September 29, 2011, 5:46am UTC](https://discuss.gradle.org/t/what-is-task-syntactically-in-task-sometask-map/6416 "2011-09-29T05:46:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![thor\_kummer](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@thor\_kummer](https://discuss.gradle.org/u/thor_kummer)\
**Post date:** [September 29, 2011, 5:46am UTC](https://discuss.gradle.org/t/what-is-task-syntactically-in-task-sometask-map/6416/1 "2011-09-29T05:46:00Z")

</div>

I can understand most of the syntax of Gradle in terms of Groovy but the syntactic role of ‘task’ in this context eludes me. I assume ‘sometask’ is a method call (to an undefined method) with a map and a closure as arguments, that Gradle intercepts and uses to define ‘sometask’. But I’m not clear about the syntactic role of ‘task’. Is it a method call or something else?

---

<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:** [September 29, 2011, 11:32am UTC](https://discuss.gradle.org/t/what-is-task-syntactically-in-task-sometask-map/6416/2 "2011-09-29T11:32:00Z")

</div>

It’s hard to understand because it’s actually transformed at compile time. Defining tasks is such a common thing to do so we added some syntactic sugar.

If you have:

```gradle
task myTask(type: Copy) {
  }

```

During compile time this is actually transformed to:

```gradle
task("myTask", type: Copy) {
  }

```

Which is a syntax you can also use if you need to.

---

<div class="post-metadata">

**Author:** ![hansd](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/hansd/32/3_2.png) [@hansd](https://discuss.gradle.org/u/hansd)\
**Post date:** [September 29, 2011, 11:42am UTC](https://discuss.gradle.org/t/what-is-task-syntactically-in-task-sometask-map/6416/3 "2011-09-29T11:42:00Z")

</div>

We do this with the help of Groovy’s AST transformation capability.

---

<div class="post-metadata">

**Author:** ![thor\_kummer](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@thor\_kummer](https://discuss.gradle.org/u/thor_kummer)\
**Post date:** [September 29, 2011, 12:37pm UTC](https://discuss.gradle.org/t/what-is-task-syntactically-in-task-sometask-map/6416/4 "2011-09-29T12:37:00Z")

</div>

Ok, is this the only place where Gradle syntax deviates from Groovy’s? Or is there a list somewhere of the differences?

---

<div class="post-metadata">

**Author:** ![hansd](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/hansd/32/3_2.png) [@hansd](https://discuss.gradle.org/u/hansd)\
**Post date:** [September 29, 2011, 12:45pm UTC](https://discuss.gradle.org/t/what-is-task-syntactically-in-task-sometask-map/6416/5 "2011-09-29T12:45:00Z")

</div>

There is one other area where we use AST transformations. This is the buildscript block:

```gradle
buildscript {
   ...
}

```

The syntax is groovy, but as it adds to the script classpath, it is evaluated before the actual Groovy build script is compiled.

There is no place where we explicitly document the place where we use Groovy AST’s.

---

<div class="post-metadata">

**Author:** ![thor\_kummer](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@thor\_kummer](https://discuss.gradle.org/u/thor_kummer)\
**Post date:** [September 30, 2011, 9:31am UTC](https://discuss.gradle.org/t/what-is-task-syntactically-in-task-sometask-map/6416/6 "2011-09-30T09:31:00Z")

</div>

Good to know. Thanks.
