Steve Appling wrote:
Adam Murdoch wrote:
Steve Appling wrote:
Tom Eyckmans wrote:
2009/5/6 Adam Murdoch <[email protected]
<mailto:[email protected]>>
<clip>
I'm curious, how we will make this available to tasks?
You'd implement a ChangeProcessor that gets notified of what has
changed, depending how the task works you can just keep a list of
the files / directories that have changed and execute the function
of the task on the list or execute the function of the task in the
ChangeProcessor methods.
Currently the change detection always scans for all files /
directories that have changed, this is not always needed so I'll
add mulitple old / new state comparison strategies. So you can have
only one event if the directory has changed in some way or for
every file / directory that has changed.
When I was experimenting with Tom's change detection, I added a
dependsOnDir method to Task that used his ChangeProcessor. If
nothing in the dir changed, it would throw a
StopExecutionException. This seemed to work well for customizing
some simple user defined tasks.
This is a good idea - it's simple, but is probably sufficient for 90%
of custom tasks.
I'm not sure about the method name - do we want to reuse 'dependsOn'
or use a different term?
Adam
That is a good point, Adam. This is very different from the other
dependencies, in some ways this is the opposite (stopping tasks
instead of adding more to the DAG). I think there may be a range of
these user specified optimizations. How about this instead:
Task gets a new method, onlyIf that takes a closure. The closure is
run before any actions and is expected to return a boolean. If the
boolean is true, then the task continues executing normally, if it
returns false, the task is stops execution, but logs an appropriate
lifecycle message "skipped (optimized)".
The onlyIf closure runs with a delegate of a new class, an
OptimizationHelper, that has some of the helper methods for various
checks like Tom's change detection. This could look like:
myTask.onlyIf {
dirChanged(file 'src/main/java')
}
or
myTask.onlyIf { !file('build/someresult').exists() }
I really like this idea.
Adam
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email