Provide mvn command output when VERBOSE set

According to [1] when CalledProcessError is thrown it contains failed
command output. Print it out when command fails in VERBOSE mode so that
it can be easier determined what went wrong.

[1] https://docs.python.org/2/library/subprocess.html#subprocess.CalledProcessError

Change-Id: I6b31bc7a4e93a947366e1381430a3b591fdab172
Signed-off-by: Jacek Centkowski <jcentkowski@collab.net>
This commit is contained in:
Jacek Centkowski 2018-02-07 12:44:05 +01:00
parent dcaa305ec6
commit 3509776800

View File

@ -16,7 +16,7 @@
from __future__ import print_function
from optparse import OptionParser
from os import path, environ
from subprocess import check_output
from subprocess import check_output, CalledProcessError
from sys import stderr
opts = OptionParser()
@ -67,6 +67,8 @@ for spec in args.s:
except Exception as e:
print('%s command failed: %s\n%s' % (args.a, ' '.join(exe), e),
file=stderr)
if environ.get('VERBOSE') and isinstance(e, CalledProcessError):
print('Command output\n%s' % e.output, file=stderr)
exit(1)