I have 2 Exec tasks. Output from one task should be an input for another:
task bar(type: Exec) {
commandLine('./someShellScript')
standardOutput = new ByteArrayOutputStream()
ext.output = {
return standardOutput.toString()
}
}
task foo(type: Exec) {
dependsOn bar
commandLine('./someOtherSript,'
bar.ext.output()) //this is an output from first task
standardOutput = new ByteArrayOutputStream()
ext.output = {
return standardOutput.toString()
}
}
But after I wrote this, I realized that evaluation of foo's commandLine happens at the configuration stage (bar.ext.output() is called before bar is executed).
How do I make this kind of connection between these 2 Exec tasks when one acts as input for another?
with no success, the closure is called at evaluation time (the example above makes no sense per se, imagine that the list we add to cmd comes from another taskās output)
Using a GString?
No, that is a Groovy thing.
But the arguments are all evaluated lazily using toString().
So you can supply any object that lazily in toString() calculates the value.