请问谁用过ANT,具体怎么用?
首先安装ANT
假定Ant安装在c:\ant\目录下。下面是设定环境的命令:
set ANT_HOME=c:\ant
set JAVA_HOME=c:\j2sdk1.4.1
set PATH=%PATH%;%ANT_HOME%\bin
运行Ant非常简单,当你正确地安装Ant后,只要输入ant就可以了。
没有指定任何参数时,Ant会在当前目录下查询build.xml文件。如果找到了就用该文件作为buildfile。如果你用-find 选项。Ant就会在上级目录中寻找buildfile,直至到达文件系统的根。要想让Ant使用其他的buildfile,可以用参数-buildfile file,这里file指定了你想使用的buildfile的文件名。
你也可以设定一些属性,以覆盖buildfile中指定的属性值。可以用 -Dproperty=value 选项,这里property是指属性的名称,而value则是指属性的值。也可以用这种办法来指定一些环境变量的值。你也可以用property task来存取环境变量。只要将 -DMYVAR=%MYVAR% (Windows) 或 -DMYVAR=$MYVAR (Unix) 传递给Ant -你就可以在你的buildfile中用${MYVAR}来存取这些环境变量。
还有两个选项-quite,告诉Ant运行时只输出少量的必要信息,如:BUILD SUCCESSFUL。而-verbose,告诉Ant运行时要输出更详细的信息。
可以指定执行一个或多个target。当省略target时,Ant使用标签<project>的default属性所指定的target。
-projecthelp选项输出项目的描述信息和项目target的列表。先列出那些有描述的,然后是没有描述的target。
命令行选项总结:
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 which 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
-D<property>=<value> set property to value
例子
ant
使用当前目录下的build.xml运行Ant,执行缺省的target。
ant -buildfile test.xml
使用当前目录下的test.xml运行Ant,执行缺省的target。
ant -buildfile test.xml dist
使用当前目录下的test.xml运行Ant,执行一个叫做dist的target。
ant -buildfile test.xml -Dbuild=build/classes dist
使用当前目录下的test.xml运行Ant,执行一个叫做dist的target,并设定build属性的值为build/classes。
Ant的buildfile是用XML写的。每个buildfile都含有一个project。
常用的元素有"project"、"target"、"path"、"property"等。
常用的任务有"ant"、"mkdir"、"delete"、"copy"、"javac"、"jar"、"javadoc"、"echo"等
以上只是该工具的一点皮毛,熟能生巧,相信不久你也能够运用自如了!
GOOD LUCK!
"这个工具装上以后是不是IE之类的浏览器呀" ?????
Ant 是一个编译工具, myftp() 说得很清楚
请看以下连接:
http://www.chedong.com/tech/ant.html
http://www.chinajavaworld.net/doc/wangyou/qiwang/ant_practice.htm
Ant初步
http://www.zdnet.com.cn/developer/tech/story/0,2000081602,39098978,00.htm