在进行“关于Ant环境配置的问题”中的正确环境配置后,可以测试Ant构建。
首先:建立文件helloAnt.xml,内容如下:
<?xml version="1.0"?>
<project name="helloAnt">
<target name="sayHello">
<echo message="Hello Ant"/>
</target>
</project>
然后:进入DOS命令环境,进入helloAnt.xml文件保存的目录下,此处为E:\Ant-Exercise
输入:
E:\Ant-Exercise>ant –f helloAnt.xml回车后会出现:
Buildfile: helloAnt does not exist!
Build failed
需要改为:
E:\Ant-Exercise>ant –f helloAnt.xml sayHello回车会出现
Buildfile: E:\Ant-Exercise\helloAnt.xml
sayHello:
[echo] Hello Ant
BUILD SUCCESSFUL
Total time: 0 seconds
说明测试成功。
注意:在E:\Ant-Exercise>ant –f helloAnt.xml sayHello中最后面的sayHello为helloAnt.xml文件中target 的name值。