I would like to speed up the build by deploying (with a system call to scp) in parallel threads, but I need to notify the user at the end of the build if any of the deployments failed. (It’s not enough to print an error message to the console in the middle of the build because that would force the users to watch the entire thing.) There is an afterEvaluate life cycle method but no afterExecute. Is there something else I can hook into?
@Leonard: The would be optimal, but the system call to “scp” happens in a new new thread. An execption in that thread is just written to the console and the main thread continues. At least when I rethrew the execption that occured.
@Luke: My ‘deploy’ task takes a closure that starts a thread to run the “scp” and “ssh” system commands. A semaphore limits it to 10 concurrent threads (The default max number of concurrent scp calls on my system).
The code is below. The action is factored out into a method because other sub-projects have different source and destination name for the deployments.
@Leonard: I considered GPars very briefly, but I have no experience with it and I didn’t immediatly see a way to limit the number of concurrent threads to 10 or how to apprach it when there is no collection to give to GPars, so a semaphore seemed a quicker solution. But, it is an argument from ignorance (of GPars).
@Leonard: Probably I could. I would like to know the answer to the question anyway since I think could be useful in other cases. For example to display some sort of statistics after the build. Gradle is such a general framework that I’ld be surpriced if there isn’t a way to do this.