I would like for one task to be dependent on another conditionally. The way I 
have tried this is as follows:

task foo {
  //Do stuff
}

task bar << {
  //do other stuff
}

bar.doFirst {
  def aFile = file("/path/to/file")
  if (!aFile.exists()) {
    println "Doesn't exist"
    dependsOn foo
  }
}

Unfortunately, even though executing bar produces the "Doesn't exist" 
statement, foo doesn't execute before  bar. It doesn't execute at all.

Any insight into how I can enable conditional task dependencies is appreciated.

Thanks.


Reply via email to