How can I ensure all output from Ant's exec ta

2020-02-04 11:04发布

The Ant exec task has an output property which can be used to tell Ant where the output goes. I've used it to redirect the output to a file. The thing is, if I don't do something with the output, the stuff that Ant prints isn't that much of a help - it's not complete.

Is there someway of setting the output property to System.out?

标签: ant exec
7条回答
我欲成王,谁敢阻挡
2楼-- · 2020-02-04 11:46

Working with Ant and Gruntjs:

For anyone trying to get this to work using Gruntjs. I was able to get it working by doing the following (in combination with darcyparker's answer).

In my Ant Build File:

<target description="run grunt js tasks" name="grunt">  
    <exec  dir="/path/to/grunt" executable="cmd" failonerror="true">
        <arg value="/c"/>
        <arg value="jshint.bat"/> // I broke each task into it's own exec
        <arg line=" &gt; jshint.log 2&lt;&amp;1"/>
        <arg line=" || (type jshint.log &amp; del jshint.log &amp; exit /b 1)"/>
        <arg line=" &amp; type jshint.log &amp; del jshint.log &amp;"/>
    </exec>
    <exec  dir="/path/to/grunt" executable="cmd" failonerror="true">
        // another grunt task (IE: uglify, cssmin, ect..)
    </exec>
</target>

jshint.bat

@echo off
pushd "C:\path\to\grunt\" 
@ECHO _____________________________________________
@ECHO GRUNT JSHINT
@ECHO _____________________________________________
grunt jshint --stack >>jshint.log

NOTE: Path to grunt would be where your Gruntfile.js is located. Also note, I had to initially create the log file (to get it to work with darcyparker's answer) which would output the stack trace from that particular task. This would then give me the grunt task stack output from wherever I call my ant target.

Finally note that pushd "C:\path\to\grunt\" won't be necissary if your bat files are in the same directory as your Gruntfile.js.

查看更多
登录 后发表回答