Ant编译和部署工具build.xml的编写
2009-11-29 11:50
381 查看
<?xml version="1.0" encoding="UTF-8"?>
<project name="shopping" basedir="." default="all">
<!-- 系统环境变量的设定 -->
<property name="tomcat.home" value="C:/Program Files/Apache Software Foundation/Tomcat 5.5" />
<!-- 本地系统路径设定 -->
<property name="servlet-api.jar" value="${tomcat.home}/common/lib/servlet-api.jar" />
<property name="jsp-api.jar" value="${tomcat.home}/common/lib/servlet-api.jar" />
<property name="distpath.project" value="${tomcat.home}/webapps" />
<!-- 工程设定 -->
<property name="project.distname" value="shopping" />
<!-- 路径设定 -->
<property name="dir.src" value="src" />
<property name="dir.webinf" value="WebContent/WEB-INF" />
<property name="dir.classes" value="${dir.webinf}/classes" />
<!-- 编译的类路径设定 -->
<path id="compile.classpath">
<pathelement path="${dir.classes}" />
<pathelement path="${classpath}" />
<pathelement path="${servlet-api.jar}" />
<pathelement path="${jsp-api.jar}" />
<fileset dir="${dir.webinf}/lib">
<include name="*.jar" />
</fileset>
</path>
<!-- prepare用于定义前的准备工作 -->
<target name="prepare">
<tstamp />
</target>
<!-- resources用于实现对资源文件和配置文件的部署 -->
<target name="resources">
<copy todir="${dir.classes}" includeEmptyDirs="no">
<fileset dir="${dir.src}">
<patternset>
<include name="**/*.conf" />
<include name="**/*.properties" />
<include name="**/*.xml" />
<include name="**/*_zh_CN.properties" />
</patternset>
</fileset>
</copy>
<native2ascii src="${dir.src}" dest="${dir.classes}" includes="**/*_zh_CN.properties" encoding="gb2312" />
</target>
<!-- compile编译所有的Java文件 -->
<target name="compile" depends="prepare,resources">
<javac srcdir="${dir.src}" destdir="${dir.classes}">
<classpath refid="compile.classpath" />
</javac>
</target>
<!-- clean主要用于清除已经编译的目标文件和已经部署的文件 -->
<target name="clean" description="Prepare for clean build">
<delete dir="${dir.classes}" />
<delete dir="${distpath.project}/${project.distname}" />
<delete dir="${distpath.project}/${project.distname}.war" />
<mkdir dir="${dir.classes}" />
</target>
<!-- project重新编译所有的JAVA文件 -->
<target name="project" depends="clean,prepare,compile" />
<!-- dist用于完成项目的部署工作 -->
<target name="dist" description="Create binary distribution">
<war basedir="WebContent" warfile="${distpath.project}/${project.distname}.war" webxml="${dir.webinf}/web.xml">
<exclude name="${distpath.project}/${project.distname}.war" />
</war>
</target>
<!-- all用于重新编译和部署整个应用 -->
<target name="all" depends="project,dist" />
</project>
以上配置编译和部署通过。
<project name="shopping" basedir="." default="all">
<!-- 系统环境变量的设定 -->
<property name="tomcat.home" value="C:/Program Files/Apache Software Foundation/Tomcat 5.5" />
<!-- 本地系统路径设定 -->
<property name="servlet-api.jar" value="${tomcat.home}/common/lib/servlet-api.jar" />
<property name="jsp-api.jar" value="${tomcat.home}/common/lib/servlet-api.jar" />
<property name="distpath.project" value="${tomcat.home}/webapps" />
<!-- 工程设定 -->
<property name="project.distname" value="shopping" />
<!-- 路径设定 -->
<property name="dir.src" value="src" />
<property name="dir.webinf" value="WebContent/WEB-INF" />
<property name="dir.classes" value="${dir.webinf}/classes" />
<!-- 编译的类路径设定 -->
<path id="compile.classpath">
<pathelement path="${dir.classes}" />
<pathelement path="${classpath}" />
<pathelement path="${servlet-api.jar}" />
<pathelement path="${jsp-api.jar}" />
<fileset dir="${dir.webinf}/lib">
<include name="*.jar" />
</fileset>
</path>
<!-- prepare用于定义前的准备工作 -->
<target name="prepare">
<tstamp />
</target>
<!-- resources用于实现对资源文件和配置文件的部署 -->
<target name="resources">
<copy todir="${dir.classes}" includeEmptyDirs="no">
<fileset dir="${dir.src}">
<patternset>
<include name="**/*.conf" />
<include name="**/*.properties" />
<include name="**/*.xml" />
<include name="**/*_zh_CN.properties" />
</patternset>
</fileset>
</copy>
<native2ascii src="${dir.src}" dest="${dir.classes}" includes="**/*_zh_CN.properties" encoding="gb2312" />
</target>
<!-- compile编译所有的Java文件 -->
<target name="compile" depends="prepare,resources">
<javac srcdir="${dir.src}" destdir="${dir.classes}">
<classpath refid="compile.classpath" />
</javac>
</target>
<!-- clean主要用于清除已经编译的目标文件和已经部署的文件 -->
<target name="clean" description="Prepare for clean build">
<delete dir="${dir.classes}" />
<delete dir="${distpath.project}/${project.distname}" />
<delete dir="${distpath.project}/${project.distname}.war" />
<mkdir dir="${dir.classes}" />
</target>
<!-- project重新编译所有的JAVA文件 -->
<target name="project" depends="clean,prepare,compile" />
<!-- dist用于完成项目的部署工作 -->
<target name="dist" description="Create binary distribution">
<war basedir="WebContent" warfile="${distpath.project}/${project.distname}.war" webxml="${dir.webinf}/web.xml">
<exclude name="${distpath.project}/${project.distname}.war" />
</war>
</target>
<!-- all用于重新编译和部署整个应用 -->
<target name="all" depends="project,dist" />
</project>
以上配置编译和部署通过。
相关文章推荐
- java ant进行编译打包,build.xml文件编写
- ant 全功能编译打包部署ftp启动服务的 build.xml
- ANT部署EJB应用的build.xml
- Apache Ant编写build.xml的自动提示 ANT DTD
- Ant编译生成war文件的build.xml文件示例
- [置顶] Ant中的build.xml文件的详细部署
- junit与ant整合的build.xml的编写-----非常重要,看懂这个,你就懂了ant的90%了
- ant build.xml compile 编译 指定 jar
- ANT及build.xml文档编写
- Ant的build.xml的编写学习
- 如何编写Build文件对手机软件的编译打包----使用antenna和ant
- AndroidSDK内置ANT编译build.xml
- ant编译android程序时报错,build.xml:49: taskdef class com.android.ant.SetupTask cannot be found
- ant的安装、使用,build.xml简单编写
- ant 编译android程序 执行build.xml文件到打包资源文件时候报错!提示找不到资源文件!
- ANT build.xml 编译出错Error running javac.exe compiler
- 实习杂记(23):build.xml进行ant编译的时候target的执行顺序
- Ant打包编译部署工具学习笔记
- 如何编写Build对文件手机软件的编译--使用antenna和ant
- ant build.xml文档编写