First off, I am already aware of GRADLE-427. I am also aware of mustRunAfter and dependsOn. I have found .execute() to be unreliable.
In all my code, including builds, I strive for reuse of code. mustRunAfter and dependsOn permanently attach relationships to other tasks to the present task. This interferes with the reuse of tasks. This is fairly obvious with dependsOn because it forces other tasks to run, and subtler with mustRunAfter where adding a new dependency can disrupt a previously well sorted order in an unclear fashion, and precludes a reverse ordering at any time in the future.
Consider this:
task stopTomcat << {
println 'Stopping tomcat...'
def proc = project.ext.stopT.execute()
proc.waitFor()
sleep 3000
}
task startTomcat << {
println 'Starting tomcat...'
def proc = project.ext.startT.execute()
proc.waitFor()
}
I may well want to start tomcat, do something (UI tests?) and then stop tomcat. I may also want to stop tomcat, do something (drop a jar in /lb?) and then start it again. I may also want to start tomcat and have gradle finish, test my code manually, then run a task to stop tomcat.
In all cases order is important, and must be as specified, and it’s not acceptable for either task to require the other to be run first. This situation leaves me red in the face with bulging veins screaming at the screen “I know the order! Let me tell you the #$#@% order”
Ok maybe not but it has wasted a bunch of my time, and is beginning to make me look silly for having promoted gradle in our project… The ability to execute segments of code in a particular order is something one assumes is there and it’s quite a shock to find out that it’s not possible! If people ask me about this I can only say… “uh it’s a suprise to me too”
Functions are not the solution because I want to do these sorts of things with extensions of the Copy task too, and you can’t convert a task to a function, and execute() in a function is unreliable.
Personally I would find it most convenient if you just did what GRADLE-427 asked for, but any syntax that works is fine with me, even making execute reliable.