Taskgraph.whenready and ext properties


i had the idea to check the value of some ext properties after the configuration phase has been finished. So i added a taskGraph.whenReady handler. But i wondered why the handler doesn’t see ext properties that have been changed in the configuration. See this example:

ext {
 myProp = 'initial'
  task MyTask() {
 println "MyTask config 1: $myProp"
 ext.myProp = 'Now changed'
 println "MyTask config 2: $myProp"
  gradle.taskGraph.whenReady { graph ->
    if (graph.hasTask(MyTask)) {
  println "whenReady: $myProp"

The output is

C:\temp>gradle MyTask
MyTask config 1: initial
MyTask config 2: Now changed
whenReady: initial
  Total time: 4.582 secs

The whenReady{} has still the initialization value set. I’m certainly missing something, but what?

There isn’t one ‘ext’ namespace but many. In particular, all objects that are ‘ExtensionAware’ (projects, tasks, configurations, etc.) have their own extra properties. In the code above, you are “changing” (really setting) the extra property for ‘MyTask’, but later you are getting the extra property for the project (because the task isn’t in scope here). Changing this to ‘MyTask.myProp’ should give the expected result.

PS: I recommend to start task names with a lowercase letter.

Great! Learnt another lesson. Thank you.