Configuration on demand doesn't allow for tasks addition in "projectEvaluated"?


(Appu Goundan) #1

Configuration on demands causes different behavior when used under certain conditions. This is a toy example, but it show what’s going on.

build.gradle

task hello << {
  println "hello"
}
  task hello2 << {
  println "hello2"
}
  project.gradle.projectsEvaluated {
  if(project.tasks.getByName("hello")) {
    hello.dependsOn hello2
  }
}

------------------------ running “gradle hello”

with configurationOnDemand = false

:hello2 hello2 :hello hello

with configurationOnDemand = true

Configuration on demand is an incubating feature. :hello hello


Is this expected?


(Appu Goundan) #2

Looks like using

project.afterEvaluate

is a workaround.