@@ -21,16 +21,18 @@ public class LoggedExec extends Exec {
21
21
22
22
public LoggedExec () {
23
23
ByteArrayOutputStream output = new ByteArrayOutputStream ();
24
+ ByteArrayOutputStream error = new ByteArrayOutputStream ();
24
25
if (getLogger ().isInfoEnabled () == false ) {
25
26
setStandardOutput (output );
26
- setErrorOutput (output );
27
+ setErrorOutput (error );
27
28
setIgnoreExitValue (true );
28
29
doLast ((unused ) -> {
29
30
if (getExecResult ().getExitValue () != 0 ) {
30
31
try {
31
- for (String line : output .toString ("UTF-8" ).split ("\\ R" )) {
32
- getLogger ().error (line );
33
- }
32
+ getLogger ().error ("Standard output:" );
33
+ getLogger ().error (output .toString ("UTF-8" ));
34
+ getLogger ().error ("Standard error:" );
35
+ getLogger ().error (error .toString ("UTF-8" ));
34
36
} catch (UnsupportedEncodingException e ) {
35
37
throw new GradleException ("Failed to read exec output" , e );
36
38
}
@@ -65,17 +67,19 @@ private static <T extends BaseExecSpec> ExecResult genericExec(
65
67
return function .apply (action );
66
68
}
67
69
ByteArrayOutputStream output = new ByteArrayOutputStream ();
70
+ ByteArrayOutputStream error = new ByteArrayOutputStream ();
68
71
try {
69
72
return function .apply (spec -> {
70
73
spec .setStandardOutput (output );
71
- spec .setErrorOutput (output );
74
+ spec .setErrorOutput (error );
72
75
action .execute (spec );
73
76
});
74
77
} catch (Exception e ) {
75
78
try {
76
- for (String line : output .toString ("UTF-8" ).split ("\\ R" )) {
77
- project .getLogger ().error (line );
78
- }
79
+ project .getLogger ().error ("Standard output:" );
80
+ project .getLogger ().error (output .toString ("UTF-8" ));
81
+ project .getLogger ().error ("Standard error:" );
82
+ project .getLogger ().error (error .toString ("UTF-8" ));
79
83
} catch (UnsupportedEncodingException ue ) {
80
84
throw new GradleException ("Failed to read exec output" , ue );
81
85
}
0 commit comments