首页 > 代码库 > ant 安装

ant 安装

1、下载地址:http://ant.apache.org/bindownload.cgi

2、安装:

       1、window以下:

             解压apache-ant-1.8.4-bin.zip 到某个文件夹 F:\tools\apache-ant

            环境变量加入 ANT_HOME    F:\tools\apache-ant

                                      path 追加 F:\tools\apache-ant\bin 

             測试:ant

                        C:\Documents and Settings\zhangchao02>ant
                         Buildfile: build.xml does not exist!
                         Build failed

             測试成功

         2、linux以下:

                解压 cd /usr/local/src   tar -zxvf apache-ant-1.8.4-bin.tar.gz

                环境变量 /etc/profile  加入        export  ANT_HOME=/usr/local/src/apache-ant-1.8.4

                                                                         path 追加 /usr/local/src/apache-ant-1.8.4/bin

                                                                         source /etc/profile

                 測试 ant -version

                 Apache Ant(TM) version 1.8.4 compiled on May 22 2012

  3、ant 具体说明

        1、參考地址:http://www.cnblogs.com/clarkchen/archive/2011/03/10/1980194.html

              http://blog.csdn.net/user4570/article/details/4221101

            http://www.blogjava.net/Files/dreamstone/ant3.rar

        <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="jar" name="TestDemo">
 <target name="A" if="ant.java.version">
  <echo message="Java Version: ${ant.java.version}" />
  <delete dir="build" />
 </target>
 <target name="main" depends="A" unless="amigo">
  <description>
    test depends
     </description>
  <echo message="first ant xml ${basedir}" />
  <mkdir dir="build"/>
  <mkdir dir="build/class"/>
  <javac srcdir="src" destdir="build/class" />
 </target>
 <target name="run" depends="main">
  <java classname="HelloGame">
   <classpath>
    <pathelement path="build/class"/>
   </classpath>
  </java>
 </target>
 <target name="jar" depends="run">
  <jar destfile="helloGame.jar" basedir="build/class">
   <manifest>
    <attribute name="Main-class" value=http://www.mamicode.com/"HelloGame" />
   </manifest>
  </jar>
 </target>
</project>

       

      
                

ant 安装