On 29/11/2010, at 12:11 PM, Steven Devijver wrote:
> Hey,
>
> I'm trying to implement something straightforward: add upToDateWhen closures
> to various tasks to deliberately not have them run when it is not desirable.
> However, my attempts are frustrated by the .gradle folder. When I delete the
> .gradle folder my tasks are never up-to-date, that is: tasks are always
> executed at least once regardless of the return value of the upToDateWhen
> closure.
>
> Is there a way to have pure upToDateWhen behavior that works predictably
> regardless of the contents of the .gradle folder?
Currently, Gradle considers that a task is up-to-date when all of its
upToDateWhen predicates return true and the declared task outputs are
up-to-date wrt the declared inputs. That is, there's an implicit upToDateWhen
predicate which checks the declared outputs. If any of the predicates
(including the implicit one) returns false, then Gradle considers the task
outputs as out-of-date and executes the task.
There's no way at the moment to override this default behaviour.
You could use the onlyIf() method instead: someTask.onlyIf { ... some predicate
.. }
The .gradle folder is where Gradle tracks the history of the tasks. If this
folder is deleted, Gradle has no way of knowing the state of the inputs and
outputs when the task last ran (if at all), and so must execute the task at
least once to collect this.
Is there some reason you are deleting the .gradle folder? Gradle assumes that
the .gradle folder is long lived, and persists a (growing) set of state there.
Perhaps that assumption is not a good one.
--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz