ExecException should add command line arguments, stdin, stdout & present working directory information

When using project.exec(…) to run command line operations, the output it gives is very limited. This makes it very hard to debug and understand what the problem is. This request is to modify ExecException to include information about the command line arguments, present working directory, stdout & stderr output. All of which would make it much easier to debug. Though it’s possible to retrieve this data with extra coding, it’s tricky to do and instead should be included by default.

For example:

proj.exec {
    executable 'ls'
    args 'DOES-NOT-EXIST'

This will currently output:

org.gradle.process.internal.ExecException: Process 'command 'ls'' finished with non-zero exit value 1

This is next to useless as it misses out the following:

  • Command line arguments
  • Present Working Directory
  • stdout
  • stderr

Even though a caller may provide a stdout & stderr streams, the project.exec(…) command, Gradle could internally use a TeeOutputStream to maintain it’s own copy of the output for each. I’m not clear on whether it should interleave or separate stdout and stdin but I’m fine with either.

My workaround to this, forces the caller to provide the execSpec, stdout and stderr streams and then reconstructs a much more detailed exception.

Though verbose, this output is much more helpful.

The current code doesn’t do anything more than list the executable that failed: