Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When executing a batch file with ant's <code>apply</code> or <code>exec</code> tasks on Windows, I found there are special cases where some of the stdout and stderr is not captured by ant. (For example: if you call a batch file that in turn calls other commands (like <code>node.exe</code>), then the stdout and stderror from the child <code>node.exe</code> process is lost.)</p> <p>I spent a long time trying to debug this! It seems that the batch file's stdout and stderr is captured, however commands called by the batch file are somehow not seen by ant. (perhaps because they are separate child processes). Using the <code>output</code> and <code>error</code> attributes as suggested above doesn't help because only <em>some</em> of the stdout and/or stderr is captured.</p> <p>The solution I came up with (a <em>hack</em>) is to add these arguments at the end of the command:</p> <pre><code>&lt;!--Next arg: forces node's stderror and stdout to a temporary file--&gt; &lt;arg line=" &amp;gt; _tempfile.out 2&amp;lt;&amp;amp;1"/&gt; &lt;!--Next arg: If command exits with an error, then output the temporary file to stdout, --&gt; &lt;!--delete the temporary file and finally exit with error level 1 so that --&gt; &lt;!--the apply task can catch the error if @failonerror="true" --&gt; &lt;arg line=" || (type _tempfile.out &amp;amp; del _tempfile.out &amp;amp; exit /b 1)"/&gt; &lt;!--Next arg: Otherwise, just type the temporary file and delete it--&gt; &lt;arg line=" &amp;amp; type _tempfile.out &amp;amp; del _tempfile.out &amp;amp;"/&gt; </code></pre> <p>Because this <em>hack</em> only applies to windows, remember to add <code>@osfamily="windows"</code> to the <code>apply</code> or <code>exec</code> task. And create similar task(s) for `@osfamily="unix", etc but without these extra arguments.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload