ant给shell脚本传递参数
Ant也可以通过命令行参数 -buildfile
可以输入ant -help查看
命令行可选参数摘要:
ant [options] [target [target2 [target3] …]]
Options:
-help print this message
-projecthelp print project help information
-version print the version information and exit
-quiet be extra quiet
-verbose be extra verbose
-debug print debugging information
-emacs produce logging information without adornments
-logfile file use given file for log output
-logger classname the class that is to perform logging
-listener classname add an instance of class as a project listener
-buildfile file use specified buildfile
-find file search for buildfile towards the root of the filesystem and
use the first one found
-Dproperty=value set property to value
解释:
-buildfile
-find
-help,-p:显示ant的命令帮助信息。在命令行中显示ant的命令选项及简短的介绍,-h是简写。
-version:显示ant 的版本信息。
-diagnostics:显示ant项目的运行环境、依赖库等信息,为错误诊断和报告提供一些有用的帮助信息。
-quiet,-q: 隐藏ant执行的提示输出信息。命令行将不会输出具体的target的执行信息。
-verbose,-v: 显示ant执行的详细信息,包括操作系统和Java环境等信息。
-debug,-d:显示ant执行调试的信息、详细的log信息。
-lib
-logfile
例如:执行 ant -f test.xml -l c:\testAntLog.log 将会百日志信息输出到c:\testAntLog.log去。
-D
例如:ant -f test.xml -Dsrc=hello
注:D和参数名之间没有空格。
实例:
1、shell脚本如下:
#!/bin/bash
echo my name is $1
echo my age is $2
2、build.xml如下:
<?xml version=”1.0” ?>
3、执行命令如下:
ant -f build.xml -Darg1=liuxiao -Dage=29
4、结果:
还没有评论,来说两句吧...