隨筆-199  評論-203  文章-11  trackbacks-0
           1、下載安裝下載:http://ant.apache.org

              需要設(shè)置的環(huán)境變量:

              ANT_HOME:ant的安裝目錄

              JAVA_HOME:jdk的安裝目錄

              PATH:把%ANT_HOME%\bin目錄加到path變量,以便于從命令行下直接運行ant

              假定ant解壓在c:\ant   jdk裝d:\j2sdk1.4.0

              則在命令行下執(zhí)行以下命令:

          set ANT_HOME=c:\ant
          set JAVA_HOME=D:\j2sdk1.4.0
          set PATH=%PATH%;c:\ant\bin

              2、工程文件目錄結(jié)構(gòu):

              一個ant 工程目錄結(jié)構(gòu):

              C:\workspace\ant.test:工程主目錄

              \src :源程序目錄

              \build\classes :編譯后的 class 文件目錄

              \lib :開發(fā)工程所需要的類庫目錄,比如開發(fā)數(shù)據(jù)庫時所需要的 jdbc lib(這次沒用到)

              \jar :打包好的 jar 程序目錄(這次沒用到)

              \build.xml :工程配置文件\build.propertiees:工程資源文件

              2、建立工程描述文件和建立工程資源文件

              建立工程描述文件build.xml

          <?xml version="1.0"?>

          <project default="main" basedir=".">

              <echo message="pulling in property files" />
              <property file="build.properties" />

              <target name="init">
                  <echo message="init. delete the old class files. and create the new folds." />
                  <delete dir="${classpath}" />
                  <mkdir dir="${classpath}" />
              </target>

              <target name="compile" depends="init">
                  <echo message="compile the java source files." />
                  <javac srcdir="src\hello\ant" destdir="${classpath}" />
              </target>

              <target name="main" depends="compile">
                  <echo message="calling java to run this java project." />
                  <java classname="hello.ant.HelloAnt">
                      <classpath>
                          <pathelement path="${classpath}" />
                      </classpath>
                  </java>
              </target>

          </project>

              建立工程資源文件:build.properties

              文件內(nèi)容是下面一行內(nèi)容:

          classpath=build\\classes

              4、建立java源文件:hello.ant.HelloAnt.java

          package hello.ant;

          public class HelloAnt {
              public static void main(String[] args) {
                  System.out.println("hello ant, the first time using ant... it is great.");
              }
          }

              5、編譯:

          C:\workspace\ant.test>ant -buildfile build.xml
          Buildfile: build.xml
               [echo] pulling in property files

          init:
               [echo] init. delete the old class files. and create the new folds.
             [delete] Deleting directory C:\workspace\ant.test\build\classes
              [mkdir] Created dir: C:\workspace\ant.test\build\classes

          compile:
               [echo] compile the java source files.
              [javac] Compiling 1 source file to C:\workspace\ant.test\build\classes

          main:
               [echo] calling java to run this java project.
               [java] hello ant, the first time using ant... it is great.

          BUILD SUCCESSFUL
          Total time: 890 milliseconds

          C:\workspace\ant.test>

          posted on 2009-08-20 22:07 Werther 閱讀(1397) 評論(0)  編輯  收藏 所屬分類: 18.Other

          I'm reading...

          Java 60

          Head  First SQL

          寶貝連接


          If you need these books,pls send me emails.
          Email:kunpeng.niu@163.com
          <2009年8月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345

          留言簿(10)

          隨筆分類(178)

          隨筆檔案(208)

          文章檔案(1)

          新聞檔案(6)

          相冊

          1.Java Official Website

          2.Java Study Website

          3.Java Technic Website

          4.Java Video Website

          5.Database Website

          6.Bookshop Website

          7.English Website

          8.Friends Link

          9.Other Web

          積分與排名

          • 積分 - 686097
          • 排名 - 67

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 惠水县| 娄烦县| 旺苍县| 偃师市| 诸城市| 彭州市| 洪雅县| 外汇| 晴隆县| 汽车| 全南县| 南充市| 富宁县| 香格里拉县| 阿拉善左旗| 兴文县| 鱼台县| 大荔县| 工布江达县| 剑河县| 衡南县| 张家港市| 博白县| 祁门县| 昔阳县| 自贡市| 平湖市| 阿克苏市| 咸丰县| 东阳市| 孝义市| 赤壁市| 原平市| 隆昌县| 文成县| 宣恩县| 炉霍县| 拉萨市| 泊头市| 阿拉善左旗| 渝北区|