@@ -56,7 +56,6 @@ public abstract class LoggedExec extends DefaultTask implements FileSystemOperat
5656 protected FileSystemOperations fileSystemOperations ;
5757 private ProjectLayout projectLayout ;
5858 private ExecOperations execOperations ;
59- private boolean spoolOutput ;
6059
6160 @ Input
6261 @ Optional
@@ -84,6 +83,9 @@ public abstract class LoggedExec extends DefaultTask implements FileSystemOperat
8483 @ Input
8584 abstract public Property <File > getWorkingDir ();
8685
86+ @ Internal
87+ abstract public Property <Boolean > getSpoolOutput ();
88+
8789 private String output ;
8890
8991 @ Inject
@@ -95,14 +97,16 @@ public LoggedExec(ProjectLayout projectLayout, ExecOperations execOperations, Fi
9597 // For now mimic default behaviour of Gradle Exec task here
9698 getEnvironment ().putAll (System .getenv ());
9799 getCaptureOutput ().convention (false );
100+ getSpoolOutput ().convention (false );
98101 }
99102
100103 @ TaskAction
101104 public void run () {
105+ boolean spoolOutput = getSpoolOutput ().get ();
102106 if (spoolOutput && getCaptureOutput ().get ()) {
103107 throw new GradleException ("Capturing output is not supported when spoolOutput is true." );
104108 }
105- if (getCaptureOutput ().getOrElse ( false ) && getIndentingConsoleOutput ().isPresent ()) {
109+ if (getCaptureOutput ().get ( ) && getIndentingConsoleOutput ().isPresent ()) {
106110 throw new GradleException ("Capturing output is not supported when indentingConsoleOutput is configured." );
107111 }
108112 Consumer <Logger > outputLogger ;
@@ -156,7 +160,9 @@ public void run() {
156160 if (getLogger ().isInfoEnabled () == false ) {
157161 if (exitValue != 0 ) {
158162 try {
159- getLogger ().error ("Output for " + getExecutable ().get () + ":" );
163+ if (getIndentingConsoleOutput ().isPresent () == false ) {
164+ getLogger ().error ("Output for " + getExecutable ().get () + ":" );
165+ }
160166 outputLogger .accept (getLogger ());
161167 } catch (Exception e ) {
162168 throw new GradleException ("Failed to read exec output" , e );
@@ -173,10 +179,6 @@ private String byteStreamToString(OutputStream out) {
173179 return ((ByteArrayOutputStream ) out ).toString (StandardCharsets .UTF_8 );
174180 }
175181
176- public void setSpoolOutput (boolean spoolOutput ) {
177- this .spoolOutput = spoolOutput ;
178- }
179-
180182 public static ExecResult exec (ExecOperations execOperations , Action <ExecSpec > action ) {
181183 return genericExec (execOperations ::exec , action );
182184 }
0 commit comments