Ant [常用方法]
来源:互联网 发布:php只能做网站吗 编辑:程序博客网 时间:2024/06/08 17:11
主要是用到ant中的env这个值, environment的前三个字符。 使用方法:
<project name="Build" default="test" basedir=".">
<property environment="env"/>
<property name="SystemRoot.path" value="${env.SystemRoot}" />
<property name="ANT_HOME.path" value="${env.ANT_HOME}" />
<property name="OS.type" value="${env.OS}" />
<target name="test">
<echo message="The path of system root: ${SystemRoot.path}" />
<echo message="The path of ant home: ${ANT_HOME.path}" />
<echo message="The type of OS: ${OS.type}" />
</target>
</project>
2. ant中怎么调用cmd中的命令
使用<exec executable="cmd">和其参数<arg line="/c ......" />
比如我要用cmd中的方式输出当前的日期和时间:
<project name="Build" default="test" basedir=".">
<target name="test">
<exec executable="cmd">
<arg line="/c echo Hi, dude, the date is %date%, and the time is %time%" />
</exec>
</target>
</project>
3. ant中怎么执行第三方程序
与上面类似, 只不过executable的值换成第三方app地址, 参数line的值换成app需要的参数值
4. ant怎么传入参数
ant命令后面这样加参数 ant -DYourArgName=YourArgValue, 就是参数要跟在-D后面, 然后build文件就可以通过 ${YourArgName}使用这个参数了。
比如我要传入两个参数BuildProject.name和BuildProject.info
ant -DBuildProject.name=ATestProject -DBuildProject.info=nothing
Build文件中就可以这样使用
<project name="Build" default="test" basedir="."><target name="test"><echo message="The project name is ${BuildProject.name}, and this guy wants to say ${BuildProject.info}" /></target></project>
5. ant中如何从文件里读取内容
使用ant中的loadfile命令,可以将文件内容读取到一个property中
<project name="Build" default="test" basedir=".">
<target name="test">
<loadfile property="MessageFromFile" srcFile="ContentInFile.txt"/>
<echo message="${MessageFromFile}" />
</target>
</project>
6. ant中如何输出log到文件
如果打算把整个ant执行都输出到Log,请使用ant的 -l 参数
ant -l antlog.log
如果只是想在ant中输出想输出的信息到log, 请参考第2条
<project name="Build" default="test" basedir=".">
<target name="test">
<exec executable="cmd">
<arg line="/c echo print this message to the log>>log.txt" />
</exec>
</target>
</project>
- Ant [常用方法]
- Ant 的常用方法例子
- ant的常用设置
- Ant 常用Task
- Ant 常用任务
- 常用ant的操作
- Ant常用模板(转)
- ant常用task
- ANT常用标签
- Ant 常用任务
- ant 常用标签
- ant 常用文件操作
- ofbiz 常用ant命令行
- Ant 常用标签
- ant常用的标签
- ofbiz 常用ant命令行
- ant常用功能
- ant常用标签
- 解决BitBlt 覆盖按钮问题
- Intent的setFlags()方法
- VxWorks操作系统入门教程
- Rendering ink and image to a bitmap using WPF
- Linux 磁盘“Block Size”研究
- Ant [常用方法]
- C语言实现打开一个文件(有内容的),统计这个文件中字符e出现了多少次
- updating partition key column would case a partition change
- Cursor的moveToFirst和moveToNext .
- 关于Linux静态库和动态库的分析
- Firefox从HTML文件导入由360安全浏览器/IE导出的书签时的乱码问题
- Web开发人员应当收藏的10个网站
- Cheat Engine Tutorial v3--翻译Cheat Engine 6.1 tutorial(3)
- UILabel多行并根据高度动态显示文本