ant学习一(ant部署)

1、什么是Ant
Apache Ant是一款基于java的构建的工具。有如下优点:
Ant是纯Java语言编写的,所示具有很好的跨平台性。操作简单。Ant是由一个内置任务和可选任务组成的。Ant运行时需要一个XML文件(构建文件)。Ant通过调用target树,就可以执行各种task。每个task实现了特定接口对象。由于Ant的构建文件是XML格式的,所以很容易维护和书写,而且结构很清晰。由于Ant的跨平台性和操作简单的特点,它很容易集成到一些开发环境中去。
2、Ant下载安装
1)到Apache官网下载ant安装文件,将其解压到你的工作目录
下载地址:http://ant.apache.org/bindownload.cgi
我的机器是XP的,下载zip包后解压,路径为D:\apache-ant-1.8.4
2)配置环境变量
如果不配置环境变量,在使用ant命令时,前面必须给出ant.bat的路径;配置ant环境变量后,在命令提示符下直接输入ant targetname即可。
添加ANT_HOME环境变量,变量值为E:\apache-ant-1.8.4
修改PATH环境变量,在变量值中添加%ANT_HOME%\bin
3、运行Ant
当你正确的安装Ant并配置环境变量以后,运行Ant非常简单,运行---cmd,打开命令提示符,进入到你要运行的ant脚本目录,然后输入ant命令即可。例如,我的build.xml位于F盘的AntTest目录中,那么打开命令提示符,然后进入到F:\AntTest目录,然后输入ant命令,则会执行build.xml中指定的默认的target。
ant命令格式(ant -h可查看下面的信息):
ant [options] [target [target2 [target3] ...]]
Options:
-help, -h print this message
-buildfile <file> use given buildfile
-file <file> ''
-f <file> ''
-projecthelp, -p print project help information(只有具有description的target才会列出)
-version print the version information and exit
-diagnostics print information that might be helpful to
diagnose or report problems.
-quiet, -q be extra quiet
-verbose, -v be extra verbose
-debug, -d print debugging information
-emacs, -e produce logging information without adornments
-lib <path> specifies a path to search for jars and classes
-logfile <file> use given file for log
-l <file> ''
-logger <classname> the class which is to perform logging
-listener <classname> add an instance of class as a project listener
-noinput do not allow interactive input
-D<property>=<value> use value for given property
-keep-going, -k execute all targets that do not depend
on failed target(s)
-propertyfile <name> load all properties from file with -D
properties taking precedence
-inputhandler <class> the class which will handle input requests
-find <file> (s)earch for buildfile towards the root of
-s <file> the filesystem and use it
-nice number A niceness value for the main thread:
1 (lowest) to 10 (highest); 5 is the default
-nouserlib Run ant without using the jar files from
${user.home}/.ant/lib
-noclasspath Run ant without using CLASSPATH
-autoproxy Java1.5+: use the OS proxy settings
-main <class> override Ant's normal entry point
例子
1)ant
使用当前目录下的build.xml运行Ant,执行缺省的target(<project>标签的default属性所指定的target)。
2)ant -buildfile test.xml
使用当前目录下的test.xml运行Ant,执行缺省的target。
3)ant -buildfile test.xml dist
使用当前目录下的test.xml运行Ant,执行一个叫做dist的target。
4)ant -buildfile test.xml -Dbuild=build/classes dist
使用当前目录下的test.xml运行Ant,执行一个叫做dist的target,并设定build属性的值为build/classes。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值