How can I ensure all output from Ant's exec task goes to stdout?

后端 未结 7 1984
情歌与酒
情歌与酒 2020-12-09 09:52

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

相关标签:
7条回答
  • 2020-12-09 10:30

    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.

    0 讨论(0)
提交回复
热议问题