Ant生成脚本来运行一个批处理文件,当通过用户输入批处理文件 [英] Ant build script to run a batch file, while passing user input to batch file

查看:210
本文介绍了Ant生成脚本来运行一个批处理文件,当通过用户输入批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写,是为了执行一个.bat文件,以向用户提供前pressing输入回车执行ant脚本构建脚本。我已经使用了bat文件,和它的作品很好,但我从来没有尝试过一个bat文件整合到一个构建脚本,尤其是一个需要输入。无需输入组件的构建脚本应该是这样的,我相信:

I am writing a build script that is meant to execute a .bat file, with the user providing input before pressing enter to execute the ant script. I have used the bat file already, and it works well, but I have never tried integrating a bat file into a build script before, especially one that requires input. The build script without the input component should look like this I believe:

<target name="css-val">
    <exec dir="M:\burnjc_view\ServiceTeams\Team 4\Report\CssValidation\bin" executable="cmd" os="Windows 7">
        <arg line="/c cssvalFile.bat"/>
    </exec>
</target>

这需要投入正常运行BAT文件看起来是这样的:

The bat file that requires input to run properly looks like this:

java -jar css-validator.jar -output gnu file:///%1 > ..\output\%2

输入1是由CSS-validator.jar进行验证的文件的文件和目录,而2是输出的文件名。

Input 1 is the file and directory of a file to be validated by css-validator.jar, while 2 is the filename of the output.

我如何获得Ant脚本通过输入所执行的批处理文件,以便它的工作原理就像有人本身执行bat文件?我知道用户输入来运行整个事情的第一部分将是蚁CSS-VAL,但后来我不知道如何通过输入bat文件。

How do I get the ant script to pass input to the bat file it is executing so that it works almost like someone was executing the bat file by itself? I know the first part of the user input to run the whole thing will be "ant css-val", but afterward I do not know how to pass input to the bat file.

推荐答案

您可以通过传递参数 -D 开关:

You can pass parameters using -D switch:

-D<property>=<value>    Defines a property name-value pair on the command line.

,你可以参考这个参数与 $ {&LT;性&gt;}

例如:

<target name="css-val">
    <exec dir="M:\burnjc_view\ServiceTeams\Team 4\Report\CssValidation\bin" executable="cmd" os="Windows 7">
        <arg line="/c cssvalFile.bat ${file1} ${file2}"/>
    </exec>
</target>

和在运行

ant -Dfile1=somefile -Dfile2=somefile build.xml

希望这有助于

这篇关于Ant生成脚本来运行一个批处理文件,当通过用户输入批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆