On 31/10/2013, at 3:02 PM, johnrengelman <john.r.engel...@gmail.com> wrote:

> We've implemented a couple new features in our build using the 'finalizedBy'
> feature but I'm seeing some behavior that I'm not sure is correct.
> 
> Assume we have this build
> 
> tasks a, b, c, d
> 
> a.finalizedBy d
> c.dependsOn [a, b]
> a.onlyIf { project.hasProperty('foo') }
> b.onlyIf { !project.hasProperty('foo') }
> 
> when I execute this build without the 'foo' property, then I expect only b
> and c to execute and a and d to be skipped.
> 
> However, what I see is that b, c, and d execute and a is skipped.
> 
> So it appears that the 'finalizedBy' task (d) executes regardless event
> though the parent task (a) was skipped.
> 
> Is this expected behavior or should the finalizing task also skip in this
> scenario?

It's expected.

Skipping a task doesn't affect the execution of any other task. It's the most 
sensible default as it gives downstream tasks more flexibility as they can 
inspect the upstream task and make their own decision on what to run.

Consider this:

task startDb {}
task stopDb {}

task updateDbSchema {
        dependsOn startDb
        finalizedBy stopDb
        onlyIf { dbNeedsUpdate() }
}

Skipping updateDbSchema doesn't change the fact that I need to stop the db. 

If skipping tasks propagated through the graph it would be very difficult to 
reason about in a sufficiently large graph.

-- 
Luke Daley
Principal Engineer, Gradleware 
http://gradleware.com

Join us at the Gradle eXchange 2013, Oct 28th in London, UK: 
http://skillsmatter.com/event/java-jee/gradle-exchange-2013


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to