- tomcat:ant war
- weblogic:ant aarInsideWar
<project basedir="." default="usage" name="webservice">
<target name="init">
<!-- property settings -->
<property name="Name" value="webservice" />
<property name="name" value="webservice" />
<property name="aarName" value="webservice" />
<property name="version" value="3.1.1" />
<property name="year" value="2010" />
<echo message="----------- ${Name} ${version} [${year}] ------------" />
<property name="debug" value="off" />
<property name="optimize" value="on" />
<property name="deprecation" value="on" />
<!--<property name="mycedatasycn.location" value="D:/project/myce/mycedatasycn" />-->
<!-- services.xml路径 -->
<property name="servicesxml" value="${basedir}/WebRoot/WEB-INF/services/PersonManagerWsServiceImpl/META-INF/services.xml">
</property>
<!-- java源文件路径 -->
<property name="src.dir" value="${basedir}/src" />
<!-- jar包路径 -->
<property name="lib.dir" value="${basedir}/WebRoot/WEB-INF/lib" />
<!-- webapp路径 -->
<property name="webapp.dir" value="${basedir}/WebRoot" />
<property name="packages" value="net.carefx.empi.*" />
<!-- 准备源文件路径 -->
<property name="build.src" value="${basedir}/AntBuild/build" />
<!-- 编译源文件路径 -->
<property name="build.dest" value="${basedir}/AntBuild/bin" />
<!-- 准备webapp文件路径 -->
<property name="buildwar.dest" value="${basedir}/AntBuild/warsrc" />
<!-- 准备javadoc文件路径 -->
<property name="build.javadocs" value="${basedir}/AntBuild/doc" />
<!-- 打包jar文件路径 -->
<property name="jar.dest" value="${basedir}/AntBuild/jar" />
<!-- 打包war文件路径 -->
<property name="war.dest" value="${basedir}/AntBuild/war" />
<!-- 打包aar文件路径 -->
<property name="aar.dest" value="${basedir}/AntBuild/aar" />
<!-- tomcat-home路径 -->
<property name="tomcat.home" value="D:/software_files/apache-tomcat-6.0.18" />
<!--
<property name="j2eelib.dir" value="C:/Program Files/MyEclipse/eclipse/plugins/com.genuitec.eclipse.j2eedt.core_3.9.210/data/libraryset/1.4" />
-->
<!-- classpath
<fileset dir="${j2eelib.dir}">
<include name="**/*.jar"/>
</fileset>
-->
<path id="classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
<!--<pathelement location="lib/"/>-->
</path>
<filter token="year" value="${year}" />
<filter token="version" value="${version}" />
<filter token="date" value="${TODAY}" />
<filter token="log" value="true" />
<filter token="verbose" value="true" />
</target>
<!-- =================================================================== -->
<!-- Help on usage -->
<!-- =================================================================== -->
<target name="usage" depends="init">
<echo message="${Name} Build file" />
<echo message="-------------------------------------------------------------" />
<echo message="" />
<echo message=" available targets are:" />
<echo message="" />
<echo message=" jar --> generates the ${name}.jar file" />
<echo message=" build --> compiles the source code" />
<echo message=" javadoc --> generates the API documentation" />
<echo message=" clean --> cleans up the directory" />
<echo message="" />
<echo message=" Please rename build.properties.default to build.properties" />
<echo message=" and edit build.properties to specify JSDK 2.3 classpath." />
<echo message="" />
<echo message=" See the comments inside the build.xml file for more details." />
<echo message="-------------------------------------------------------------" />
<echo message="" />
<echo message="" />
</target>
<!-- =================================================================== -->
<!-- 准备源文件-->
<!-- =================================================================== -->
<target name="prepare-src" depends="init">
<!-- create directories -->
<mkdir dir="${build.src}" />
<mkdir dir="${build.dest}" />
<mkdir dir="${jar.dest}" />
<mkdir dir="${war.dest}" />
<mkdir dir="${buildwar.dest}" />
<mkdir dir="${aar.dest}" />
<!-- copy src files -->
<copy todir="${build.src}">
<fileset dir="${src.dir}" />
</copy>
<copy todir="${buildwar.dest}">
<fileset dir="${webapp.dir}" />
</copy>
</target>
<!-- =================================================================== -->
<!-- 编译源文件-->
<!-- =================================================================== -->
<target name="build" depends="clean,prepare-src">
<javac srcdir="${build.src}" destdir="${buildwar.dest}/WEB-INF/classes" debug="${debug}" optimize="${optimize}">
<classpath refid="classpath" />
</javac>
<copy todir="${buildwar.dest}/WEB-INF/classes">
<fileset dir="${build.src}">
<include name="**/*.xml" />
</fileset>
</copy>
</target>
<!-- =================================================================== -->
<!-- 打aar包-->
<!-- =================================================================== -->
<target name="aar" depends="build">
<copy file="${servicesxml}" tofile="${build.src}/META-INF/services.xml" overwrite="true" />
<jar basedir="${build.src}" destfile="${aar.dest}/${name}.aar" />
</target>
<!-- =================================================================== -->
<!-- 打war包-->
<!-- =================================================================== -->
<target name="war" depends="build">
<war warfile="${war.dest}/${Name}.war" basedir="${buildwar.dest}" webxml="${buildwar.dest}/WEB-INF/web.xml">
</war>
</target>
<!-- =================================================================== -->
<!-- 打war包【包含aar包】 能在weblogic中发布-->
<!-- =================================================================== -->
<target name="aarInsideWar" depends="aar">
<copy file="${aar.dest}/${name}.aar" tofile="${buildwar.dest}/WEB-INF/services/${name}.aar" overwrite="true" />
<copy file="${src.dir}/hibernate.properties" tofile="${buildwar.dest}/WEB-INF/classes/hibernate.properties"/>
<war warfile="${war.dest}/${Name}.war" basedir="${buildwar.dest}" webxml="${buildwar.dest}/WEB-INF/web.xml">
</war>
</target>
<!-- =================================================================== -->
<!-- 发布到本的resin和tomcat-->
<!-- =================================================================== -->
<target name="publish" depends="war,clean">
<copy todir="${tomcat.home}/webapps">
<fileset dir="${war.dest}">
<include name="**/*.war" />
</fileset>
</copy>
</target>
<!--
<target name="SyncMain">
<java classname="com.ce.synchronization.main.SyncMain" failοnerrοr="true" fork="yes">
<classpath refid="classpath"/>
</java>
</target>
-->
<!-- =================================================================== -->
<!-- 产生javadoc api 文档-->
<!-- =================================================================== -->
<target name="javadoc" depends="build">
<mkdir dir="${build.javadocs}" />
<javadoc packagenames="${packages}" sourcepath="${build.src}" destdir="${build.javadocs}" author="true" version="true" use="true" splitindex="true" windowtitle="${Name} API" doctitle="${Name}">
<classpath refid="classpath" />
</javadoc>
</target>
<!-- =================================================================== -->
<!-- 清除临时文件-->
<!-- =================================================================== -->
<target name="clean" depends="init">
<delete dir="${build.src}" />
<delete dir="${buildwar.dest}" />
<delete>
<fileset dir="${build.dest}" includes="**/*.class" />
</delete>
<delete dir="${basedir}/AntBuild">
</delete>
</target>
</project>