How to run some task after exec task completed?

Hi, I have a build scripts:

defaultTasks "rasterize"
  task rasterize(type:Exec) {
     workingDir "./"
     executable "adl.exe"
     args [
          "app.xml",
          "swf2xml"
     ]
       doLast {
          onRasterizationComplete();
     }
}
  void onRasterizationComplete() {
     result = rasterize.getExecResult();
}

and it works!

But how run some task after complete exec process instead a method? like a:

defaultTasks "printResult"
  task rasterize(type:Exec) {
     workingDir "./"
     executable "adl.exe"
     args [
          "app.xml",
          "swf2xml"
     ]
}
  task printResult {
     result = rasterize.getExecResult();
}
  printResult.dependsOn rasterize

The printResult task printed ‘null’ before the rasterize task completed… why? and how I can resolve it?

It’s the classical configuration phase vs. execution phase pitfall. Your code is configuring the ‘printResult’ task, and all configuration happens before any execution. What you really want is to add a task action:

task printResult {
  dependsOn rasterize
  doLast { // add a task action
    println rasterize.execResult
  }
}

Thanks, now understood )