Ant编译生成war文件的build.xml文件示例

我用的开发环境:eclipse 3.1+tomcat 4.1.31。示例Ant  的build.xml如下:

<?xml version="1.0" encoding="UTF-8" ?>
<project name="TradeData" default="TradeData.war">

 <!-- properies -->
 <property name="user.name" value="xiedd" />
 <property name="version" value="1.0.0" />
 <property name="src.dir" value="../src" />
 <property name="classes.dir" value="../WebRoot/classes" />
 <property name="lib.dir" value="../WebRoot/lib" />
 <property name="dist.dir" value="../build/release" />
 <property name="dist.dir" value="../build/release" />
 <property name="war.dir" value="../WebRoot" />

 <!-- 定义classpath -->
 <path id="master-classpath">
  <fileset file="${lib.dir}/*.jar" />
  <pathelement path="${classes.dir}" />
 </path>

 <!-- 初始化任务 -->
 <target name="init">
 </target>

 <!-- 编译 -->
 <target name="compile" depends="init" description="compile the source files">
  <rmdir dir="${classes.dir}" />
  <mkdir dir="${classes.dir}" />
  <javac srcdir="${src.dir}" destdir="${classes.dir}" target="1.4">
   <classpath refid="master-classpath" />
  </javac>
 </target>

 <!-- 测试
<target name="test" depends="compile" description="run junit test">
<mkdir dir="${report.dir}"/>
<junit printsummary="on"
haltonfailure="false"
failureproperty="tests.failed"
showoutput="true">
<classpath refid="master-classpath" />
<formatter type="plain"/>
<batchtest todir="${report.dir}">
<fileset dir="${classes.dir}">
<include name="**/*Test.*"/>
</fileset>
</batchtest>
</junit>
<fail if="tests.failed">
***********************************************************
**** One or more tests failed! Check the output ... ****
***********************************************************
</fail>

</target>
-->
 <!-- 打包成war -->
 <target name="TradeData.war" description="make .war file">
  <mkdir dir="${dist.dir}" />
    <war warfile="${dist.dir}/TradeData-${version}.war" webxml="${war.dir}/WEB-INF/web.xml">
     <!--<lib dir="${war.dir}/WEB-INF/lib"/>
     <classes dir = "${war.dir}/WEB-INF/classes"/>-->
     <fileset dir="${war.dir}">
     </fileset>
     <manifest>
      <attribute name="Built-By" value="${user.name}" />
       <section name="common">
          <attribute name="Implementation-Title" value="apple TradeData.war" />
          <attribute name="Implementation-Version" value="${version}" />
          <attribute name="Implementation-Vendor" value="apple" />
       </section>
      </manifest>
    </war>
  <!--
  <jar destfile="${dist.dir}/TradeData-${version}.jar" basedir="${classes.dir}">
   <exclude name="**/*Test.*" />
   <exclude name="**/Test*.*" />
   <manifest>
    <attribute name="Built-By" value="${user.name}" />
    <section name="common">
     <attribute name="Implementation-Title" value="apple" />
     <attribute name="Implementation-Version" value="${version}" />
     <attribute name="Implementation-Vendor" value="OWASP" />
    </section>
   </manifest>
  </jar>-->
 </target>

 <!-- 输出api文档 -->
 <!--
 <target name="doc" depends="pack" description="create api doc">
  <mkdir dir="${doc.dir}" />
  <javadoc destdir="${doc.dir}" author="true" version="true" use="true" windowtitle="kbase-apidoc">
   <packageset dir="${src.dir}" defaultexcludes="yes">
    <include name="example/**" />
   </packageset>
   <doctitle>
    <![CDATA[<h1>apple</h1>]]></doctitle>
  <bottom>
   <![CDATA[Copyright &#169; 2003-2006  apple All Rights Reserved.]]>
  </bottom>
  <tag name="todo" scope="all" description="To do:" />
 </javadoc>
 </target>
 -->
</project> 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值