• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    jakarta-ant的使用(java編譯工具)

    發布: 2007-7-04 13:34 | 作者: admin | 來源:  網友評論 | 查看: 90次 | 進入軟件測試論壇討論

    領測軟件測試網 一:介紹:
    ant 是jakarta的一個編譯工具,如果你了解linux/Unix下的makefile你就很容易
    理解ant的用途了。ant最適合你使用UltraEdit(EditPlus)寫java程序,然后你使用ant去編譯,同時javadoc ,生成一個jar,war,實現文件的copy都可以在build.xml通過不同的tager去實現,還是很方便的一個東東強烈推薦是使用。
    二:下載
    你可以從下面的地址下載到ant,目前版本:1.41
    http://jakarta.apache.org/builds/jakarta-ant/release/v1.4.1/bin/

    三:安裝
    a:)Windows
    1:解壓你下載的文件,會有一個jakarta-ant(版本號的)目錄產生,把他改名為ant
    2:copy ant 目錄到你需要的位置。
    3:在環境變量中添加:ANT_HOME=ant的安裝目錄,path中加$ANT_HOME$\in;注意你同時必須已經安裝了jdk,并添加了JAVA_HOME的環境變量,同時早path中加了$JAVA_HOME$\in;

    b:)Linux/Unix
    1:解壓你下載的文件,會有一個jakarta-ant(版本號的)目錄產生,把他改名為ant
    2:copy ant 目錄到你需要的位置。
    3:在環境變量中添加:ANT_HOME=ant的安裝目錄,path中加$ANT_HOME$\in;注意你同時必須已經安裝了jdk,并添加了JAVA_HOME的環境變量,同時早path中加了$JAVA_HOME$\in;實現修改環境變量你需要修改.bash_profile文件。
    如下
    ANT_HOME=/usr/local/ant
    JAVA_HOME=/usr/local/jdk
    PATH=$PATH:$HOME/bin:/usr/local/ant/bin:/usr/local/jdk/bin

    export PATH ANT_HOME JAVA_HOME

    四:編寫build.xml
    build.xml相當Linux下的makefile,具體的實現都在build.xml中實現。
    我給給例子說明一下。
    build.xml
    ================================================================
    <project name="bingo" default="build" basedir="../.." >
    <!--basedir設定工作目錄-->
    <property name="version" value="1.0"/>

    <!-- The base directory relative to which most targets are built -->
    <property name="base" value="."/>

    <!-- The directory where source files are stored. -->
    <property name="java.source.dir" value="bingo/src"/>
    <!--代碼保存路徑-->
    <!-- Destination for compiled files -->
    <property name="javac.dest" value="bingo/classes"/>
    <!--class保存路徑-->
    <!-- Destination for generated jar files -->
    <property name="jar.dest" value="bingo/jar"/>
    <!--jar文件保存路徑-->
    <!-- Destination for documentation files generated or not -->
    <property name="docs" value="bingo/docs"/>
    <!--javadoc文件保存路徑-->
    <!-- Destination for javadoc generated files -->
    <property name="javadoc.dest" value="bingo/docs"/>

    <!-- The stem where most log4j source code is located. -->
    <property name="stem" value="com/bingo"/>

    <property name="base-files" value="include"/>

    <!-- Original manifest.mf file before filtering. -->
    <property name="manifest.src" value="bingo/build/manifest.mf"/>

    <!-- Some targets needs a more precise stem. -->
    <property name="BSTEM" value="${java.source.dir}/${stem}"/>

    <property name="tomcat.dir" value="c:/Apache/Tomcat"/>

    <property name="webapp.dir" value="${tomcat.dir}/webapps/ROOT/WEB-INF/classes"/>

    <!--List all Package used in this project -->
    <property name="PackageList" value="
    com.bingo,
    com.bingo.database,
    com.bingo.dbocw,
    com.bingo.util,
    com.bingo.taglibs.jndi,
    com.bingo.finance.database,
    com.bingo.finance.entity,
    com.bingo.finance.manager"
    />
    <!--你的project中所有的包-->
    <!-- List all jar or file used in this project -->
    <property name="classpath" value="${classpath};
    ${base-files}/tomcat/servlet.jar;
    ${base-files}/tomcat/webserver.jar;
    ${base-files}/log4j/log4j.jar;
    ${base-files}/log4j/log4j-core.jar"

    />
    <!--你需要用到的包-->
    <target name="init">
    <tstamp />
    </target>

    <target name="build" depends="init">
    <echo>
    Building...
    </echo>

    <mkdir dir="${javac.dest}" />
    <javac srcdir="${java.source.dir}"
    destdir="${javac.dest}"
    classpath="${classpath}"
    debug="on"/>

    </target>
    <!-- ================================================================= -->
    <!-- Copy class files to tomcat dir. -->
    <!-- ================================================================= -->
    <target name="copy" depends="build">
    <copy todir="${webapp.dir}/com/bingo">
    <fileset dir="${javac.dest}/com/bingo">
    <include name="*.class"/>
    </fileset>
    </copy>
    <copy todir="${webapp.dir}/com/bingo/util">
    <fileset dir="${javac.dest}/com/bingo/util">
    <include name="*.class"/>
    </fileset>
    </copy>
    <copy todir="${webapp.dir}/com/bingo/database">
    <fileset dir="${javac.dest}/com/bingo/database">
    <include name="*.class"/>
    </fileset>
    </copy>
    <copy todir="${webapp.dir}/com/bingo/dbocw">
    <fileset dir="${javac.dest}/com/bingo/dbocw">
    <include name="*.class"/>
    </fileset>
    </copy>
    <copy todir="${webapp.dir}/com/bingo/finance/database">
    <fileset dir="${javac.dest}/com/bingo/finance/database">
    <include name="*.class"/>
    </fileset>
    </copy>
    <copy todir="${webapp.dir}/com/bingo/finance/entity">
    <fileset dir="${javac.dest}/com/bingo/finance/entity">
    <include name="*.class"/>
    </fileset>
    </copy>
    <copy todir="${webapp.dir}/com/bingo/finance/manager">
    <fileset dir="${javac.dest}/com/bingo/finance/manager">
    <include name="*.class"/>
    </fileset>
    </copy>
    </target>



    <!-- ================================================================= -->
    <!-- Remove all generated (compiled) class files. -->
    <!-- ================================================================= -->
    <target name="clean" depends="init">
    <delete dir="${javac.dest}/" />
    </target>

    <!-- ================================================================= -->
    <!-- Remove all backup files. -->
    <!-- ================================================================= -->
    <target name="delete" depends="init">
    <delete >
    <fileset dir="${java.source.dir}/com/bingo">
    <include name="*.bak"/>
    </fileset>
    </delete>
    <delete >
    <fileset dir="${java.source.dir}/com/bingo/util">
    <include name="*.bak"/>
    </fileset>
    </delete>
    <delete >
    <fileset dir="${java.source.dir}/com/bingo/database">
    <include name="*.bak"/>
    </fileset>
    </delete>
    <delete >
    <fileset dir="${java.source.dir}/com/bingo/finance/database">
    <include name="*.bak"/>
    </fileset>
    </delete>
    <delete >
    <fileset dir="${java.source.dir}/com/bingo/finance/entity">
    <include name="*.bak"/>
    </fileset>
    </delete>
    <delete >
    <fileset dir="${java.source.dir}/com/bingo/finance/manager">
    <include name="*.bak"/>
    </fileset>
    </delete>
    </target>



    <!-- ================================================================= -->
    <!-- Remove the temporary manifest file, actual work is done in the -->
    <!-- dependencies. -->
    <!-- ================================================================= -->

    <target name="prejar" depends="build">
    <mkdir dir="${jar.dest}"/>
    <filter token="version" value="${version}" />
    <copy file="${manifest.src}" tofile="${jar.dest}/manifest.mf"
    filtering="true"/>
    </target>

    <!-- ================================================================= -->
    <!-- This target Create bingo.jar -->
    <!-- ================================================================= -->
    <target name="jar" depends="prejar">
    <delete file="${jar.dest}/bingo.jar"/>
    <jar jarfile="${jar.dest}/bingo.jar" basedir="${javac.dest}"
    manifest="${jar.dest}/manifest.mf"
    />
    </target>

    <!-- ================================================================= -->
    <!-- This target builds the javadoc files. -->
    <!-- ================================================================= -->
    <target name="javadoc" depends="build,init">
    <mkdir dir="${javadoc.dest}" />
    <javadoc sourcepath="${java.source.dir}"
    destdir="${javadoc.dest}"
    classpath="${classpath}"
    packagenames="${PackageList}"
    version="true"
    protected="true"
    author="true"
    use="true"
    windowtitle="Bingo Free Java Code Version ${version}"
    header="Bingo Free Java Code${version}"
    />
    </target>
    </project>

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備2023014753號-2
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>