Why is my task being executed?

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

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:

task doDownload {
    doFirst {
        download {
            ....
        }
    }
}