apache ant是一个基于java的编译工具。它从功能上类似于make,但它以克服了make的缺点。ant的最初开发者在开发跨平台的应用时,发现以前的那些开发工具都有一定的限制。例如make工具,它是基于shell的,它判断一系列的条件,并像在shell下面那样执行编译命令,这样做的好处的:针对特定的平台(如 unix),可以容易的利用这些工具做编译;但同时,这也意味着,你的编译限制在固定的操作系统下,如只能用于unix同时,make文件也有一些先天的缺陷。好多人都会遇到恐怖的tab问题。ant的最初开发者多次说我的命令不能执行因为我在tab前面加了一个空格!。一些工具如jam一定程序上解决了这个问题,但仍有其它的格式问题。


 ant与从基于命令的那些扩展开来的那些工具不同,ant是由java类扩展的。不用编写shell命令,而是配置基于xml的文件,形成多个任务的目标配置树。每一个任务都是通过一个实现了一个规定接口的java类来运行的。

备注:以上解释来自互联网


 ant的官网:http://ant.apache.org/


  ant的安装有2种方法:1.二进制版本  2.源码包  


  我这里使用的是二进制版本,因为二进制版本解压,配置相关变量环境即可使用,相对源码包方便简洁。


  下面简单说一下安装步骤,


  下载软件:http://apache.fayea.com/apache-mirror//ant/binaries/apache-ant-1.9.1-bin.tar.gz   我个人比较喜欢下载到自己电脑上,之后再上传到服务器上,在我的整理文档的时候,我会按照相关内容建立文件夹:看下图,文件夹目录结构图,找什么东西都比较方便

153829562.jpg


   把软件上传到服务器上,解压  tar zxf apache-ant-1.x.tar.gz

   把整合文件包移动位置     mv apache-ant-1.x /usr/local

   然后设置相关变量


[root@zonghe local]# tail -7 /etc/profile
JAVA_HOME=/usr/local/jdk1.6.0_43
JRE_HOME=/usr/local/jdk1.6.0_43/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/jt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
export ANT_HOME=/usr/local/apache-ant-1.9.1
export PATH=$PATH:$ANT_HOME/bin


   设置好后记得 source /etc/profile


   查看一下目录结构,已经相关命令


[root@zonghe local]# cd /usr/local/
[root@zonghe local]# ll apache-ant-1.9.1/
total 376
drwxr-xr-x 2 root root   4096 Jul  1 12:02 bin
drwxr-xr-x 3 root root   4096 Jul  1 12:02 etc
-rw-r--r-- 1 root root  11253 May 16 10:36 fetch.xml
-rw-r--r-- 1 root root   4445 May 16 10:36 get-m2.xml
-rw-r--r-- 1 root root    126 May 16 10:36 INSTALL
-rw-r--r-- 1 root root  86299 May 16 10:36 KEYS
drwxr-xr-x 2 root root   4096 Jul  1 12:02 lib
-rw-r--r-- 1 root root  15289 May 16 10:36 LICENSE
drwxr-xr-x 8 root root   4096 Jul  1 12:02 manual
-rw-r--r-- 1 root root    218 May 16 10:36 NOTICE
-rw-r--r-- 1 root root   4119 May 16 10:36 README
-rw-r--r-- 1 root root 216873 May 16 10:36 WHATSNEW
[root@zonghe local]# ll apache-ant-1.9.1/bin/
total 72
-rwxr-xr-x 1 root root 10175 May 16 10:35 ant
-rw-r--r-- 1 root root  7472 May 16 10:35 ant.bat
-rw-r--r-- 1 root root  2857 May 16 10:35 ant.cmd
-rw-r--r-- 1 root root  3410 May 16 10:35 antenv.cmd
-rwxr-xr-x 1 root root   861 May 16 10:35 antRun
-rw-r--r-- 1 root root  1536 May 16 10:35 antRun.bat
-rwxr-xr-x 1 root root  2199 May 16 10:35 antRun.pl
-rwxr-xr-x 1 root root  3223 May 16 10:35 complete-ant-cmd.pl
-rw-r--r-- 1 root root  4315 May 16 10:35 envset.cmd
-rw-r--r-- 1 root root  1116 May 16 10:35 lcp.bat
-rwxr-xr-x 1 root root  4422 May 16 10:35 runant.pl
-rwxr-xr-x 1 root root  3299 May 16 10:35 runant.py
-rw-r--r-- 1 root root  1817 May 16 10:35 runrc.cmd


  ant命令的用法:


[root@zonghe bin]# ant -h
/usr/local/apache-ant-1.9.1/bin/ant [script options] [options] [target [target2 [target3] ..]]
Script Options:
  --help, --h            print this message and ant help
  --noconfig             suppress sourcing of /etc/ant.conf,
                         $HOME/.ant/ant.conf, and $HOME/.antrc
                         configuration files
  --usejikes             enable use of jikes by default, unless
                         set explicitly in configuration files
  --execdebug            print ant exec line generated by this
                         launch script
                                                   
ant [options] [target [target2 [target3] ...]]
Options:
  -help, -h              print this message
  -projecthelp, -p       print project help information
  -version               print the version information and exit
  -diagnostics           print information that might be helpful to
                         diagnose or report problems.
  -quiet, -q             be extra quiet
  -silent, -S            print nothing but task outputs and build failures
  -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
  -buildfile <file>      use given buildfile
    -file    <file>              ''
    -f       <file>              ''
  -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


     具体使用,我就不多说了,我也不是很了解,java开发应该懂,可以找身边的java开发工程师咨询。总的来说安装还是很简单的。        


     检查安装:

     

[root@zonghe manual]# ant -version
Apache Ant(TM) version 1.9.1 compiled on May 15 2013