@@ -56,7 +56,6 @@ public abstract class LoggedExec extends DefaultTask implements FileSystemOperat
56
56
protected FileSystemOperations fileSystemOperations ;
57
57
private ProjectLayout projectLayout ;
58
58
private ExecOperations execOperations ;
59
- private boolean spoolOutput ;
60
59
61
60
@ Input
62
61
@ Optional
@@ -84,6 +83,9 @@ public abstract class LoggedExec extends DefaultTask implements FileSystemOperat
84
83
@ Input
85
84
abstract public Property <File > getWorkingDir ();
86
85
86
+ @ Internal
87
+ abstract public Property <Boolean > getSpoolOutput ();
88
+
87
89
private String output ;
88
90
89
91
@ Inject
@@ -95,14 +97,16 @@ public LoggedExec(ProjectLayout projectLayout, ExecOperations execOperations, Fi
95
97
// For now mimic default behaviour of Gradle Exec task here
96
98
getEnvironment ().putAll (System .getenv ());
97
99
getCaptureOutput ().convention (false );
100
+ getSpoolOutput ().convention (false );
98
101
}
99
102
100
103
@ TaskAction
101
104
public void run () {
105
+ boolean spoolOutput = getSpoolOutput ().get ();
102
106
if (spoolOutput && getCaptureOutput ().get ()) {
103
107
throw new GradleException ("Capturing output is not supported when spoolOutput is true." );
104
108
}
105
- if (getCaptureOutput ().getOrElse ( false ) && getIndentingConsoleOutput ().isPresent ()) {
109
+ if (getCaptureOutput ().get ( ) && getIndentingConsoleOutput ().isPresent ()) {
106
110
throw new GradleException ("Capturing output is not supported when indentingConsoleOutput is configured." );
107
111
}
108
112
Consumer <Logger > outputLogger ;
@@ -156,7 +160,9 @@ public void run() {
156
160
if (getLogger ().isInfoEnabled () == false ) {
157
161
if (exitValue != 0 ) {
158
162
try {
159
- getLogger ().error ("Output for " + getExecutable ().get () + ":" );
163
+ if (getIndentingConsoleOutput ().isPresent () == false ) {
164
+ getLogger ().error ("Output for " + getExecutable ().get () + ":" );
165
+ }
160
166
outputLogger .accept (getLogger ());
161
167
} catch (Exception e ) {
162
168
throw new GradleException ("Failed to read exec output" , e );
@@ -173,10 +179,6 @@ private String byteStreamToString(OutputStream out) {
173
179
return ((ByteArrayOutputStream ) out ).toString (StandardCharsets .UTF_8 );
174
180
}
175
181
176
- public void setSpoolOutput (boolean spoolOutput ) {
177
- this .spoolOutput = spoolOutput ;
178
- }
179
-
180
182
public static ExecResult exec (ExecOperations execOperations , Action <ExecSpec > action ) {
181
183
return genericExec (execOperations ::exec , action );
182
184
}
0 commit comments