网络软件 系统工具 应用软件 图形图像 多媒体类 免费游戏 安全相关 免费音乐 网页素材 电子书籍 考试考题 建站源码
教育教学 多媒体类 编程开发 操作系统 游戏天地 娱乐天地 简历求职 站长专区 网页设计 安全技术 图形图像 文学驿站
业界资讯 | 图形图像 | 操作系统 | 网络冲浪 | 工具软件 | 办公软件 | 媒体动画 | 精文荟萃 | 认证考试 | 网页设计 | 技术开发 | 专栏
当前位置:热点网络学院编程开发Java使用 ant 让你愉快编程(2)
精品推荐
热点TOP10
·Java线程控制的图像分割与合成
·用JAVA编制电子白板软件
·Java远程方法调用 3
·JavaBean 1018
·JavaBean 10111
·J2EE 应用程序
·重构模式4
·Java Path
·JBuilder 8初探
·2003年度Javaworld编辑选择奖
·学习笔记之JAVA图形设计卷I AWT——第3章 图 形
·例说递归程序实现
·Struts tags (3) ----Bean(2)
·基于JOONE快速开发神经网络
·iText使用指南
·JDBC2.0實現數據分頁
·其它技术和Hibernate-JSP2.0
·windows定时关机程序
·Java 查看器 和 Java Plug-in 查看器之间的区别
·深入剖析Java编程中的中文问题及建议最优解决方法---下篇
使用 ant 让你愉快编程(2)
日期:2005年11月12日 作者: 查看:[大字体 中字体 小字体]
使用 ant 让你愉快编程(2)摘要: build_common.xml, common.xml 及 usage.txt2. 介绍 build_common.xml, common.xml 及 usage.txt. 以下为 build_common.xml 文件内容.
<?xml version="1.0" encoding="ISO-8859-1"?><!-- Copyright 2004 camry.wu@gmail.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA--><project name="Common build file" default="all" basedir=""><description> 这是一个通用的 ant build 文件. Version 1.0. 感谢: 这篇文档借用了很多 Johan 的想法, 他的主页在 http://dev.kanngard.net Copyright 2004 camry.wu@gmail.com</description><!-- 读入 common.xml 配置 --><xmlpropertyfile="${path.common}/common.xml" semanticAttributes="true" keepRoot="false"/><!-- 设置编译时的 classpath --><path id="compile.classpath"> <fileset dir="${path.common}/lib"><include name="*.jar"/> </fileset> <fileset dir="${lib}"><include name="*.jar"/> </fileset> <pathelement location="${dist.classes}"/></path><!-- 设置运行时的 classpath --><path id="run-time.classpath"> <path refid="compile.classpath"/></path><!-- 初始化过程, 会调用具体项目的初始化过程先 --><target name="init" depends="project_init" description="Initialize environment"></target><!-- 显示使用说明 --><target name="usage"> <loadfile property="usage.message"srcFile="${path.common}/usage.txt"/> <echo message="${usage.message}"/></target><!-- 预备, 通常在项目刚建立的时候运行此任务 --><target name="common_prepare" depends="init" description="Prepare build directory"> <copy todir="." preservelastmodified="true"><fileset dir="${path.common}/template/"><include name="**/*"/></fileset> </copy></target><!-- 配置 checkstyle , 只检查 src/main 目录下的源代码 --><target name="checkstyle" depends="init"> <taskdefresource="checkstyletask.properties"classpath="${path.common}/lib/checkstyle-all-3.4.jar"/> <checkstyle config="${build}/checkstyle_checks.xml"><fileset dir="${src.main}" includes="**/*.java"/><property key="checkstyle.cache.file" file="${path.common}/lib/checkstyle.cache"/><classpath refid="compile.classpath"/> </checkstyle></target><!-- 编译 src 下源文件, class 文件放到 dist/classes 下 --><target name="compile" depends="init" description="Compile source"> <mkdir dir="${dist}/classes"/> <javacdebug="${compile.debug}"deprecation="${compile.deprecation}"destdir="${dist}/classes"target="${compile.jdk-version.target}"source="${compile.jdk-version.source}"optimize="${compile.optimize}"srcdir="${src}"><classpath refid="compile.classpath"/> </javac></target><!-- 清除 dist 目录 --><target name="clean" depends="project_clean" description="Wipeout all generated files"> <delete dir="${dist}/classes"/> <delete dir="${dist.lib}"/> <mkdir dir="${dist}/classes"/> <mkdir dir="${dist.lib}"/></target><!-- 打包 --><target name="jar" depends="checkstyle, compile" description="Create binary distribution"> <mkdir dir="${dist}/classes"/> <mkdir dir="${dist.lib}"/> <copy file="LICENSE" todir="${dist}/classes"/> <delete><fileset dir="${dist.lib}" includes="*.jar"/> </delete> <jarbasedir="${dist}/classes" jarfile="${dist.lib}/${component.name}-${component.version}.jar"><include name="**/*.class"/><exclude name="**/Test*.class"/> </jar> <delete><fileset dir="${dist}/classes"><include name="LICENSE"/></fileset> </delete></target><!-- 运行 dist/classes 目录下的所有以 Test 开头的测试类 --><target name="test" depends="compile" description="run junit tests"> <junit printsummary="on"fork="false"haltonfailure="false"failureproperty="tests.failed"showoutput="true"><classpath refid="run-time.classpath"/><formatter type="brief" usefile="false"/><batchtest><fileset dir="${dist}/classes"> <include name="**/Test*.*"/></fileset></batchtest> </junit> <fail if="tests.failed"> ********************************************************* ********************************************************* ****One or more tests failed! Check the output...**** ********************************************************* ********************************************************* </fail></target><!-- 发布, 会调用具体项目的发布任务 --><target name="deploy" depends="project_deploy" description="Deploy application"/><!-- 创建文档 --><target name="javadoc" depends="compile" description="Create component Javadoc documentation"> <delete dir="${docs.api}"/> <mkdir dir="${docs.api}"/> <javadocauthor="true"bottom="${component.title}"destdir="${docs.api}"source="${compile.jdk-version.source}"doctitle="${component.title}"packagenames="*"access="protected"sourcepath="${src.main}"version="true"windowtitle="${component.title} (Version ${component.version})"><classpath refid="compile.classpath"/> </javadoc></target><!--根据 cvs 配置, 从 cvs 服务器上下载源代码 --><target name="fetch" depends="project_fetch" description="fetch current source from cvs"></target><!-- 将源代码文件打包, 备份 --><target name="src-zip" depends="checkstyle,compile" description="Creates source distribution"> <copy file="LICENSE" todir="${src.main}"/> <delete><fileset dir="${dist.lib}" includes="*-src.zip"/> </delete> <zipbasedir="." destfile="${dist.lib}/${component.name}-${component.version}-src.zip" whenempty="fail"><include name="**/*.*"/><include name="*"/><include name="**/*"/><exclude name="${dist}/**/*.*"/><exclude name="*.*~"/><!-- vi(JEdit) backups --><exclude name=".nbattrs"/><!-- Netbeans filesystem attributes --><exclude name="*.old"/> </zip></target><!-- 将源文件上传到服务器备份, 将目标文件上传到服务器发布. 此任务中内容由各位自行设定, 一般是运行 ftp 任务.--><target name="publish" depends="clean,jar,javadoc,src-zip" description="publish project"></target><!-- 构建 --><target name="all" depends="clean,fetch,test,jar,javadoc,deploy" description="build project"/></project>


. 以下为 common.xml 文件内容.

<?xml version="1.0" encoding="ISO-8859-1"?><!-- Copyright 2004 camry.wu@gmail.com Common Ant build environment--><root><!-- 路径配置, 基本不用改动. 但是假如你在一个陌生的环境中使用这套 build 工具, 也许需要稍为修改一下这些路径的配置.--><bin value="bin"/><build value="build"> <lib value="${build}/lib"/></build><dist value="dist"> <lib value="${dist}/lib"/> <classes id="dist.classes" location="${dist}/classes"/></dist><docs value="docs"> <api value="${docs}/api"/></docs><lib value="lib"/><src value="src"> <main value="${src}/main"/> <test value="${src}/test"/></src><!-- 编译选项 --><compile> <debug value="true"/> <deprecation value="true"/> <jdk-version><source value="1.4"/><target value="1.4"/> </jdk-version> <optimize value="true"/></compile></root>


. 以下为 usage.txt 文件内容.

${component.name} build file---------------------------------------------Available targets are:prepare --> 初始化项目环境checkstyle --> 检查源文件编码规范compile --> 编译jar--> 打包build--> 构建test --> 测试clean--> 清除deploy--> 发布到 web 服务器运行publish --> 发布产品(源码及目标文件)fetch--> 从 cvs 上获取最新资源docs --> 创建 api 文档all--> 执行 clean, fetch, build, test, doc, deploymain --> 默认的构建过程(自行修改)


下一篇

上一篇

(出处:http://down.abcdown.net/)

关于我们 | 帮助(?) | 版权声明 | 友情连接 
Copyright 2005-2005 viphot.com All Rights Reserved.
Powered by:mesky