两个build.xml文件

<!--build.properties-->

java.home=E:/j2sdk1.4.2_11/jre
src.dir=${basedir}/src
build.dir=${basedir}/WebRoot/WEB-INF
dist.dir=${basedir}/dist
web.dir=${basedir}/WebRoot


path=%path%,E:/j2sdk1.4.2_11/bin
myeclipse.j2ee.dir=E:/Program Files/MyEclipse/eclipse/plugins/com.genuitec.eclipse.j2eedt.core_3.8.4/data/libraryset/1.4

webapp.name=AngelCentre
webapp.version=1.0
webapp.war=${webapp.name}.war
tomcat.home=E:/jakarta-tomcat-5.0.28
webapp.ear=${webapp.name}.ear
earapp.xml=applicationforairline.xml
airline.log4j.properties=log4j_cuss.properties

webappforweb.name=AngelCentreWeb
webappforweb.version=1.0
webappforweb.war=${webappforweb.name}.war
webappforweb.ear=${webappforweb.name}.ear
earappforweb.xml=applicationforweb.xml
web.log4j.properties=log4j_web.properties

webappforairport.name=AngelCentreAirport
webappforairport.version=1.0
webappforairport.war=${webappforairport.name}.war
webappforairport.ear=${webappforairport.name}.ear
earappforairport.xml=applicationforairport.xml
airport.log4j.properties=log4j_airport.properties

javac.debug=true

 

 

<!--build.xml-->

<?xml version="1.0" encoding="UTF-8"?>
<project name="AngelCentre" basedir="." default="all">
 <!-- Load generally common properties, such as javac.debug -->
 <property file="build.properties"/>
 <!-- General Configuration -->
 <patternset id="java.files.pattern" includes="**/*.java"/>
 
 <target name="clean" description="Removes build artifacts">
   <delete dir="${build.dir}/classes"/>
   <delete dir="${dist.dir}"/>
 </target>
 
 <target name="init">
  <mkdir dir="${dist.dir}"/>
  <path id="common.compile.classpath">
   <fileset dir="${basedir}/WebRoot/WEB-INF/lib" includes="*.jar"/>
   <fileset dir="${myeclipse.j2ee.dir}" includes="*.jar"/>
  </path>
 </target>

 <target name="compile" depends="clean,init" description="Compile module">
  <antcall target="compile-module" inheritAll="true">
   <param name="module" value=""/>
   <reference refid="common.compile.classpath"
                    torefid="compile.classpath"
                    />
  </antcall>
 </target>
 
 <target name="copy-resources" depends="compile"
        description="Copy .properties and .xml files from source directory">
  <copy todir="${build.dir}/classes">
   <fileset dir="${src.dir}">
    <exclude name="**/*.java"/>
   </fileset>
  </copy>
 </target>

 <target name="package-war-tomcat" depends="copy-resources">
  <jar destfile="${dist.dir}/AngelCentre.war">
   <fileset dir="${web.dir}">
    <include name="**/*.properties" />
    <include name="**/*.xml" />
    <include name="**/*.hbm" />
    <include name="**/*.gif" />
    <include name="**/*.class" />
    <include name="**/*.*" />
    <exclude name="**/CVS/*.*" />
    <exclude name="**/*.db" />
    <exclude name="**/axis-ant.jar" />
    <exclude name="**/axis-bes.jar" />
    <exclude name="**/servlet-api.jar" />
    <exclude name="**/${airline.log4j.properties}" />
    <exclude name="**/${airport.log4j.properties}" />
    <exclude name="**/${web.log4j.properties}" />
   </fileset>
   <manifest>
    <attribute name="Built-By" value="Travelsky" />
   </manifest>
  </jar>
 </target>
 <!--back the log4j.properties and rename the needed file name to lgg4j.properties.-->
 <target name="copy-log4jproperties-web" depends="">
   <move tofile="${build.dir}/log4j_bak.properties" file="${build.dir}/log4j.properties"/>
   <move tofile="${build.dir}/log4j.properties" file="${build.dir}/${web.log4j.properties}"/>
 </target>
  
 <target name="copy-log4jproperties-airport" depends="">
    <move tofile="${build.dir}/log4j_bak.properties" file="${build.dir}/log4j.properties"/>
    <move tofile="${build.dir}/log4j.properties" file="${build.dir}/${airport.log4j.properties}"/>
 </target>
    
 <target name="copy-log4jproperties" depends="">
    <move tofile="${build.dir}/log4j_bak.properties" file="${build.dir}/log4j.properties"/>
    <move tofile="${build.dir}/log4j.properties" file="${build.dir}/${airline.log4j.properties}"/>
 </target>
 <target name="package-war-websphere" depends="copy-resources,copy-log4jproperties">
   <jar destfile="${dist.dir}/${webapp.war}">
    <fileset dir="${web.dir}">
     <include name="**/*.properties" />
     <include name="**/*.xml" />
     <include name="**/*.hbm" />
     <include name="**/*.gif" />
     <include name="**/*.class" />
     <include name="**/*.*" />
     <exclude name="**/CVS/*.*" />
     <exclude name="**/*.db" />
     <exclude name="**/axis-ant.jar" />
     <exclude name="**/axis-bes.jar" />
     <exclude name="**/servlet-api.jar" />
     <exclude name="**/commons-dbcp-1.1.jar" />
     <exclude name="**/${airline.log4j.properties}" />
     <exclude name="**/${airport.log4j.properties}" />
     <exclude name="**/${web.log4j.properties}" />
     <exclude name="**/log4j_bak.properties" />
    </fileset>
    <manifest>
     <attribute name="Built-By" value="Travelsky" />
     <attribute name="Add-info" value="for-airline" />
    </manifest>
   </jar>
   <move tofile="${build.dir}/${airline.log4j.properties}" file="${build.dir}/log4j.properties"/>
   <move tofile="${build.dir}/log4j.properties" file="${build.dir}/log4j_bak.properties"/>
 </target>
 
 <target name="package-war-websphere-web" depends="copy-resources,copy-log4jproperties-web">
    <jar destfile="${dist.dir}/${webappforweb.war}">
     <fileset dir="${web.dir}">
      <include name="**/*.properties" />
      <include name="**/*.xml" />
      <include name="**/*.hbm" />
      <include name="**/*.gif" />
      <include name="**/*.class" />
      <include name="**/*.*" />
      <exclude name="**/CVS/*.*" />
      <exclude name="**/*.db" />
      <exclude name="**/axis-ant.jar" />
      <exclude name="**/axis-bes.jar" />
      <exclude name="**/servlet-api.jar" />
      <exclude name="**/commons-dbcp-1.1.jar" />
      <exclude name="**/${airline.log4j.properties}" />
      <exclude name="**/${airport.log4j.properties}" />
      <exclude name="**/${web.log4j.properties}" />
      <exclude name="**/log4j_bak.properties" />
     </fileset>
     <manifest>
      <attribute name="Built-By" value="Travelsky" />
      <attribute name="Add-info" value="for-web" />
     </manifest>
    </jar>
    <move tofile="${build.dir}/${web.log4j.properties}" file="${build.dir}/log4j.properties"/>
    <move tofile="${build.dir}/log4j.properties" file="${build.dir}/log4j_bak.properties"/>
 </target>

 
 <target name="package-war-websphere-airport" depends="copy-resources,copy-log4jproperties-airport">
     <jar destfile="${dist.dir}/${webappforairport.war}">
      <fileset dir="${web.dir}">
       <include name="**/*.properties" />
       <include name="**/*.xml" />
       <include name="**/*.hbm" />
       <include name="**/*.gif" />
       <include name="**/*.class" />
       <include name="**/*.*" />
       <exclude name="**/CVS/*.*" />
       <exclude name="**/*.db" />
       <exclude name="**/axis-ant.jar" />
       <exclude name="**/axis-bes.jar" />
       <exclude name="**/servlet-api.jar" />
       <exclude name="**/commons-dbcp-1.1.jar" />
       <exclude name="**/${airline.log4j.properties}" />
       <exclude name="**/${airport.log4j.properties}" />
       <exclude name="**/${web.log4j.properties}" />
       <exclude name="**/log4j_bak.properties" />
      </fileset>
      <manifest>
       <attribute name="Built-By" value="Travelsky" />
       <attribute name="Add-info" value="for-airport" />
      </manifest>
     </jar>
     <move tofile="${build.dir}/${airport.log4j.properties}" file="${build.dir}/log4j.properties"/>
     <move tofile="${build.dir}/log4j.properties" file="${build.dir}/log4j_bak.properties"/>
 </target>
  
 <target name="package-war-bes" depends="copy-resources">
   <jar destfile="${dist.dir}/AngelCentre.war">
    <fileset dir="${web.dir}">
     <include name="**/*.properties" />
     <include name="**/*.xml" />
     <include name="**/*.hbm" />
     <include name="**/*.gif" />
     <include name="**/*.class" />
     <include name="**/*.*" />
     <exclude name="**/log4j.properties" />
     <exclude name="**/CVS/*.*" />
     <exclude name="**/*.db" />
     <exclude name="**/jaxrpc.jar" />
     <exclude name="**/vbjorb.jar" />
    </fileset>
    <manifest>
     <attribute name="Built-By" value="Travelsky" />
    </manifest>
   </jar>
 </target>
 
 <target name="clean-tomcat" description="Removes build artifacts">
   <delete dir="${tomcat.home}/webapps/AngelCentre"/>
   <delete file="${tomcat.home}/webapps/AngelCentre.war"/>
 </target>
 <target name="clean-websphere" description="Removes build artifacts">
    <delete file="${tomcat.home}/webapps/AngelCentre.war"/>
  </target>
 
 <target name="deploy-tomcat" depends="package-war-tomcat,clean-tomcat" if="tomcat.home" description="Deploy '${webapp.name}.war' to local Tomcat">
  <copy file="${dist.dir}/${webapp.war}"
            todir="${tomcat.home}/webapps"/>
 </target>
 <!--
 <target name="deploy-websphere" depends="package-war-websphere,clean-websphere" if="tomcat.home" description="Deploy '${webapp.name}.war' to local Tomcat">
   <copy file="${dist.dir}/${webapp.war}"
             todir="${tomcat.home}/webapps"/>
 </target>
 
 <target name="deploy-websphere-web" depends="package-war-websphere-web,clean-websphere" if="tomcat.home" description="Deploy '${webapp.name}.war' to local Tomcat">
    <copy file="${dist.dir}/${webappforweb.war}"
              todir="${tomcat.home}/webapps"/>
 </target>
 
 <target name="deploy-websphere-airport" depends="package-war-websphere-airport,clean-websphere" if="tomcat.home" description="Deploy '${webapp.name}.war' to local Tomcat">
   <copy file="${dist.dir}/${webappforairport.war}"
         todir="${tomcat.home}/webapps"/>
 </target>
 -->
 
 <target name="copy-applicationxml" depends=""
         description="Copy .application.xml files from base directory">
   <copy todir="${dist.dir}">
    <fileset dir="${basedir}">
     <include name="applicationforairline.xml"/>
     <include name="applicationforairport.xml"/>
     <include name="applicationforweb.xml"/>
    </fileset>
   </copy>
 </target>
 
 <target name="package-ear-websphere-web" depends="package-war-websphere-web,copy-applicationxml">
  <move tofile="${dist.dir}/application.xml" file="${dist.dir}/${earappforweb.xml}">
  </move>
  <ear destfile="${dist.dir}/${webappforweb.ear}" appxml="${dist.dir}/application.xml">
   <fileset dir="${dist.dir}">
    <include name="${webappforweb.war}" /> 
   </fileset>
   <manifest>
    <attribute name="version" value="${webappforweb.version}" />
   </manifest>
  </ear>
 </target>
 
 <target name="package-ear-websphere" depends="package-war-websphere,copy-applicationxml">
  <move tofile="${dist.dir}/application.xml" file="${dist.dir}/${earapp.xml}"/>
  <ear destfile="${dist.dir}/${webapp.ear}" appxml="${dist.dir}/application.xml" compress="true">
   <fileset dir="${dist.dir}">
    <include name="${webapp.war}" />
   </fileset>
   <manifest>
    <attribute name="version" value="${webapp.version}" />
   </manifest>
  </ear>
 </target>
 
 <target name="package-ear-websphere-airport" depends="package-war-websphere-airport,copy-applicationxml">
  <move tofile="${dist.dir}/application.xml" file="${dist.dir}/${earappforairport.xml}"/>
  <ear destfile="${dist.dir}/${webappforairport.ear}" appxml="${dist.dir}/application.xml">
   <fileset dir="${dist.dir}">
    <include name="${webappforairport.war}" /> 
   </fileset>
   <manifest>
    <attribute name="version" value="${webappforairport.version}" />
   </manifest>
  </ear>
 </target>
 
 <target name="all">
  <antcall target="package-war-tomcat"/>
 </target>

 <!-- Reusable targets invoked using antcall -->
 <target name="compile-module">
  <echo level="info">Compiling AngelCentre...</echo>
  <mkdir dir="${build.dir}/classes"/>
  <javac srcdir="src"
  destdir="${build.dir}/classes"
  debug="${javac.debug}"
  classpathref="compile.classpath"
  />
 </target>

 <!-- =================================================================== -->
 <!--            Start Tomcat                                             -->
 <!-- =================================================================== -->
 <target name="start.tomcat" depends="deploy-tomcat"
        description="starts tomcat in the current console window">
  <java classname="org.apache.catalina.startup.Bootstrap" fork="yes">
   <jvmarg value="-Dcatalina.home=${tomcat.home}"/>
   <arg value="start"/>
   <classpath>
    <pathelement path="${java.home}/../lib/tools.jar"/>
    <fileset dir="${tomcat.home}">
     <include name="bin/bootstrap.jar"/>
    </fileset>
   </classpath>
  </java>
 </target>

 <!-- =================================================================== -->
 <!-- Create JavaDoc Documentation                                        -->
 <!-- =================================================================== -->

 <target name="javadoc" description="Generate JavaDoc API docs">
  <mkdir dir="${basedir}/docs/api" />
  <javadoc destdir="${basedir}/docs/api"
              author="true"
              version="true"
              use="true"
              windowtitle="AngelCentre API">
   <packageset dir="src" defaultexcludes="yes">
    <include name="com/**" />
   </packageset>
   <doctitle>
    <![CDATA[<h1>angel apis</h1>]]></doctitle>
  <bottom>
   <![CDATA[<i>All Rights Reserved.</i>]]></bottom>
 <tag name="todo" scope="all" description="To do:" />
</javadoc>

</target>
</project>

 

<?xml version="1.0" encoding="GBK"?>
<!-- =============================================================== -->
<!-- ANT buildfile快速参考 -->
<!-- ALin 2006-12-30 14:20 -->
<!-- =============================================================== -->
<project default="help" basedir="." name="Cabin">
    <!-- project的描述,可以省略                                     -->
    <description>Ant Buildfile参考</description>

    <!-- =========================================================== -->
    <!-- 项目相关的属性设置                                          -->
    <!-- =========================================================== -->
    <property environment="env"></property><!-- 引用系统环境变量     -->
    <property name="app.nane" value="Cabin"></property>
    <property name="app.home" value="."></property>
    <property name="src.dir" value="${app.home}/src"></property>
    <property name="lib.dir" value="${app.home}/lib"></property>
    <property name="build.dir" value="${app.home}/build"></property>
    <property name="build.classes" value="${build.dir}/classes"/>
    <property name="deploy.dir" value="${app.home}/hello"/>
    <property name="deploy.classes" value="${deploy.dir}/WEB-INF/classes"/>
    <property name="TOMCAT_HOME" value="C:/Tomcat 5.5"/>
    <property name="Log4j.conf" value="log4j.configuration"></property>
    <property name="Log4j.file" value="log4j.properties"></property>
    <property name="JWSDP.HOME" value="C:/Sun/jwsdp-2.0"></property>
    <property name="JAXB.HOME" value="${JWSDP.HOME}/jaxb"></property>
   
    <property name="dtd.file1" value="datasource.dtd"></property>
    <property name="dtd.file2" value="bookList.dtd"></property>

    <property name="jboss.jar.dir"
        value="D:/Program Files/jboss-4.0.2/client"></property>
   

    <!-- =========================================================== -->
    <!-- 编译和运行的classpath                                       -->
    <!-- =========================================================== -->
    <path id="compile.classpath">
        <!-- The object files for this application -->
        <pathelement path="${build.classes}"/>
       
        <!-- 包括目录下的所有.jar和.zip文件                          -->
        <fileset dir="${TOMCAT_HOME}/common/lib">   <!-- lib的目录   -->
            <include name="*.jar"/>                 <!-- 包括jar文件 -->
            <include name="*.zip"/>
            <exclude name="*.properties"/> <!-- 不包括properties文件 -->
        </fileset>

        <!-- 可以指定具体的某个.jar文件                              -->
        <fileset dir="${jboss.jar.dir}">
            <include name="jbossall-client.jar"/>
            <include name="jnp-client.jar"/>
        </fileset>
        <!-- 可以使用location代理path                                -->
        <pathelement path="${TOMCAT_HOME}/common/classes"/>
    </path>
   
    <!-- 创建目录,如果已经存在,则跳过                              -->
    <target name="prepare">
        <mkdir dir="${src.dir}/META-INF"/>
        <mkdir dir="${bin.dir}/META-INF"/>
        <mkdir dir="${lib.dir}"/>
    </target>

    <!-- =========================================================== -->
    <!-- target设置                                                  -->
    <!-- =========================================================== -->
    <target name="compile" depends="prepare">
        <javac srcdir="${src.dir}" destdir="${build.classes}" debug="no">
            <!-- 引用上面的compile.classpath-->
            <classpath refid="compile.classpath"/>
        </javac>
    </target>
   
    <target name="copy" depends="compile">
        <!-- 把${src.dir}下面的properties文件复制到${deploy.classes} -->
        <copy todir="${deploy.classes}">
            <fileset file="${src.dir}/*.properties"/>
        </copy>
       
        <!-- 复制指定文件 -->
        <copy todir="${deploy.home}">
            <fileset file="${build.classes}/${app.name}.jar"/>
        </copy>

        <!-- 把${build.classes}下面的文件复制到${deploy.classes},包 -->
        <!-- 括.class文件,不包括.log文件,子目录中的文件也会复制。  -->
        <copy todir="${deploy.classes}">
            <fileset dir="${build.classes}">
                <include name="**/*.class"/>
                <exclude name="**/*.log"/>
            </fileset>
        </copy>
       
        <!-- 复制具体文件,覆盖已有的文件                            -->
        <copy file="src/META-INF/services.xml"
            tofile="${dest.dir.classes}/META-INF/services.xml"
            overwrite="true"/>
    </target>

    <target name="clean">
        <!-- 删除${deploy.classes}下面的所有(.class)文件-->
        <delete>
            <fileset dir="${deploy.classes}">
                <include name="*"/> <!-- 包括所有文件 -->
                <include name="*/**.class"/>
                <exclude name=""/>  <!-- ""表示不含任何文件 -->
            </fileset>
        </delete>

        <!-- 删除${bin.dir}下面的.class、.xml、.properties、.log文件 -->
        <delete>
            <fileset dir="${bin.dir}">
                <include name="**/*.class"/>
                <include name="**/*.xml"/>
                <include name="**/*.properties"/>
                <include name="**/*.log"/>
            </fileset>
        </delete>

        <!-- 删除指定路径的文件 -->
        <delete file="${deploy.home}/${app.name}.jar"></delete>
    </target>
   
    <!-- run依赖于compile和delete                                    -->
    <!-- 类似于在${bin.dir}下面执行java events.EventManager,只有    -->
    <!-- fork="YES"的情况下,dir属性才有效,使用classpathref引用前面 -->
    <!-- 的compile.classpath。                                       -->
    <!-- arg表示提供参数。运行方式:ant run -Daction=value           -->
    <!-- 其效果等同于:java events.EventManager value                -->
    <!-- 只不过不再需要用-cp指定classpath,非常方便。                -->
    <target name="run" depends="compile, clean">
        <java classname="events.EventManager" fork="YES" dir="${bin.dir}"
            classpathref="compile.classpath">
            <classpath path="${bin.dir}"/><!-- classpath不是必须的   -->
            <arg value="${action}"/>   <!-- arg也不是必须的,1或多个 -->
        </java>
    </target>
   
    <!-- 使用exec可以运行可执行文件。dir表示在某个目录下执行;       -->
    <!-- executable表示可执行文件的路径,如果在path变量中,则只要    -->
    <!-- 可执行文件名即可,否则应该给出完整路径;os表示是什么系统;  -->
    <!-- 也可以通过arg提供参数。                                     -->
    <target name="xjc">
        <echo>Run xjc.bat and generate sources.</echo>
        <exec dir="${src.dir}" executable="${JAXB.HOME}/bin/xjc.bat" os="Windows XP">
          <arg line="-dtd ${dtd.file2}"></arg>
          <!--arg value="${dtd}"></arg--><!-- DTD file as run-time argument-->
        </exec>
    </target>

    <!-- 把${bin.dir}下面的所有文件打包成:${app.name}.aar文件,并放 -->
    <!-- 置在${bin.dir}目录下。类似于在${bin.dir}目录下执行:        -->
    <!-- jar cvf Cabin.aar .                                         -->
    <target name="jar">
        <jar basedir="${bin.dir}" destfile="${bin.dir}/${app.name}.aar">
        </jar>
    </target>

    <target name="deploy">
    </target>

    <target name="help">
        <echo>ant copy                  Copy files.</echo>
        <echo>ant compile               Compile source files.</echo>
        <echo>ant/ant build             Build.</echo>
        <echo>ant run -Daction=store    Run client</echo>
        <echo>ant clean                 Clean.</echo>
        <echo>ant help                  Display this help message.</echo>
        <echo>${env.JBOSS_HOME}</echo><!-- 输出系统的JBOSS_HOME变量 -->
    </target>
</project>
 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值