# Why is my task being executed?

**URL:** <https://discuss.gradle.org/t/why-is-my-task-being-executed/3752>\
**Category:** Old Forum Archive\
**Created:** [October 31, 2013, 7:51pm UTC](https://discuss.gradle.org/t/why-is-my-task-being-executed/3752 "2013-10-31T19:51:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![J\_V](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@J\_V](https://discuss.gradle.org/u/J_V)\
**Post date:** [October 31, 2013, 7:51pm UTC](https://discuss.gradle.org/t/why-is-my-task-being-executed/3752/1 "2013-10-31T19:51:00Z")

</div>

Why is gradle executing my task? I don’t want it to.

I have a dot gradle file. I am executing :

$gradle -b my.gradle

no task is specified, but a task is being executed. I don’t want it to execute this task. It fails if the task is executed (the task references a passed in param that I am not yet passing in). Is it required to pass in variables required by a task, even if the task that uses them is not executed? I thought this would be a runtime error instead of a compile time?

What determines if a task is executed or not? and why did it pick my one task (from many) to run?

the task is:

task doDownload {

download {

,…

} }

I would expect this task not to be executed unless I specifically invoke it like:

$gradle -b my.gradle doDownLoad

---

<div class="post-metadata">

**Author:** ![daz](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/daz/32/2475_2.png) [@daz](https://discuss.gradle.org/u/daz)\
**Post date:** [October 31, 2013, 8:00pm UTC](https://discuss.gradle.org/t/why-is-my-task-being-executed/3752/2 "2013-10-31T20:00:00Z")

</div>

It’s very unlikely that your task is being executed without being called. It’s much more likely that you made the mistake of putting the code to be _executed_ in a _configuration_ block. All tasks are configured before any are executed.

Try something like:

```gradle
task doDownload {
    doFirst {
        download {
            ....
        }
    }
}

```
