本站首页    管理页面    写新日志    退出


«August 2025»
12
3456789
10111213141516
17181920212223
24252627282930
31


公告

关注电子政务、大型企业应用开发、Web、Workflow、MOM、MDA、RCP、GEF

email:gmluyang@gmail.com


链接

好友
bluedavy-林昊
刑红瑞
SixSun-翻译
Birt中文指南
SixSun-OpenDoc
Eclipse RCP and Web in action(编写中)

我的分类(专题)

日志更新

最新评论

留言板


Blog信息
blog名称:SixSun的Blog
日志总数:152
评论数量:372
留言数量:13
访问次数:2380993
建立时间:2004年12月13日




[Java Open Source]jakarta-ant的使用(java编译工具)
文章收藏,  软件技术

SixSun 发表于 2004/12/16 21:19:52

一:介绍:    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.xmlbuild.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>


阅读全文(2644) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.047 second(s), page refreshed 144774246 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号