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。
分享到:
相关推荐
Ant远程部署tomcat脚本
ant 学习笔记 ,自己的一些学的时候的一个例子
一个用于weblogic下ant部署的demo。
ant_shell自动部署
NULL 博文链接:https://chenming100-1976.iteye.com/blog/511643
教会你如何使用ant部署j2me和j2ee项目,里面有两个简单的例子,从简单的项目搭建中让你知道如何使用ant。
ant脚本,讲本地代码copy到远程linux服务器的tomcat目录下,并重启tomcat,需要下载jsch.jar包放到本地ant-home的lib目录下
ant +build.xml 文件Jenkins部署javaEE项目,助力成功自动化部署。ant +build.xml 文件Jenkins部署javaEE项目,助力成功自动化部署。ant +build.xml 文件Jenkins部署javaEE项目,助力成功自动化部署。ant +build.xml...
自己整理的在Eclipse下部署远程tomcat的步骤及相关build文件
目录 ANT简介 安装Apache Ant 验证Apache Ant的安装 安装 Eclipse Ant构建文件 Ant属性任务 Ant属性文件 Ant数据类型 Ant构建项目 ...Ant部署应用程序 Ant执行Java代码 Ant和Eclipse集成 Ant Junit集成
在Java项目开发中,ant用来打包是最好不过的工具了,有兴趣的朋友们来来看看吧。。。。。
ant在myeclipse中的部署,过程比较详细,要是还不成功,那就是你自己机子的问题
自动把补丁打到服务器上面、自动部署ant脚本、自动部署ant脚本
ant的示例代码 包括 java小项目和build.xml的配置
Ant学习套电子书配,是pdf格式的,ant是一个强大的工具,如果是学习java的同志,不管现在学习,或者以后的工作你都会用到。将一个工程葱编码到完成部署。
Ant是一个Apache基金会下的跨平台的构件工具,它可以实现项目的自动构建和部署等功能。在本文中,主要让读者熟悉怎样将Ant应用到Java项目中,让它简化构建和部署操作。 一.安装与配置 二.Ant的关键元素 三.Ant的...
apache-ant-1.8.2 源码和jar包
不会用ant打包、部署项目的工程师,不是一个好程序员(测试) 副标题:利用ant脚本 自动构建svn增量/全量 系统程序升级包 首先请允许我这样说,作为开发或测试,你一定要具备这种本领。你可以手动打包、部署你的工程...
ant工具ant资源包
ant部署文件