关于ant的build.xml、version.properties、build.properties例子

[size=large]build.xml[/size]
dist为开发环境,dist-Product为生产环境


<project name="teststrutsspring" basedir="." default="dist">
<property file="build.properties" />
<property file="version.properties" />
<property name="src" location="src" />
<property name="build" location="build" />
<property name="dist" location="dist" />
<property name="lib.dir" location="WebRoot/WEB-INF/lib" />
<property name="web" location="WebRoot" />

<target name="dist" description="Generate the distribution">
<antcall target="clean" />
<antcall target="init" />
<antcall target="getVersion" />
<antcall target="compile" />
<antcall target="copyother" />
<antcall target="jar" />
<antcall target="jarclientapi" />
<antcall target="war" />
</target>

<target name="dist-Product" description="Generate the Product">
<antcall target="clean" />
<antcall target="init" />
<antcall target="getVersion" />
<antcall target="compile" />
<antcall target="copyother" />
<antcall target="copy-product-env-config" />
<antcall target="jar" />
<antcall target="war" />
<echo>Generate the product environment!</echo>
</target>

<target name="init">
<!-- Create the time stamp -->
<tstamp />
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}" />
<mkdir dir="${dist}" />
</target>

<target name="clean" description="clean up">
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}" />
<delete dir="${dist}" />
</target>

<target name="getVersion">
<propertyfile file="version.properties" comment="This is Version File">
<entry key="buildDate" type="date" value="now" pattern="yyyy-MM-dd HH:mm:ss" />
</propertyfile>
<property file="version.properties" />
<copy todir="${build}">
<fileset dir=".">
<include name="version.properties" />
</fileset>
</copy>
</target>

<path id="all-libs">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>

<target name="compile" description="compile the source">
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}" encoding="UTF-8" nowarn="true" source="1.5">
<classpath refid="all-libs" />
</javac>
</target>

<target name="copyother">
<copy todir="${build}">
<fileset dir="${src}">
<include name="**/**" />
<exclude name="**/*.java" />
<exclude name="*.properties" />
<exclude name="*.xml" />
</fileset>
</copy>
<copy todir="${dist}/${webname}">
<fileset dir="${web}">
<include name="**/*" />
<exclude name="**/WEB-INF/classes/**" />
</fileset>
</copy>
<copy todir="${dist}/${webname}/WEB-INF/classes">
<fileset dir="${src}">
<include name="*.properties" />
<include name="*.xml" />
</fileset>
</copy>
</target>

<target name="jar" description="Generate the distribution">
<jar jarfile="${dist}/${projectname}-${version}.jar" basedir="${build}" compress="true">
</jar>
<copy todir="${dist}/${webname}/WEB-INF/lib">
<fileset dir="${dist}">
<include name="${projectname}-${version}.jar" />
</fileset>
</copy>
</target>

<target name="jarclientapi" description="Generate the jar client api">
<jar jarfile="${dist}/${clientapiname}-${version}.jar" compress="true">
<fileset dir="${build}">
<include name="**/*.class" />
</fileset>
</jar>
</target>

<target name="copy-product-env-config">
<copy todir="${dist}/${webname}/WEB-INF/classes" overwrite="true">
<fileset dir="ProductEnv-Config">
<include name="*.properties" />
</fileset>
</copy>
</target>

<target name="war">
<war basedir="${dist}/${webname}" warfile="${dist}/${webname}.war" webxml="${dist}/${webname}/WEB-INF/web.xml" compress="false">
</war>
</target>
</project>



[size=large]build.properties[/size]


projectname=teststrutsspring
webname=teststrutsspring
clientapiname=teststrutsspring-pojo


[size=large]version.properties[/size]


#This is Version File
#Fri Sep 10 11:05:45 CST 2010
version=1.0.0
buildDate=2010-09-10 11\:05\:45

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值