java: ant 脚本示例

 <?xml version="1.0" encoding="UTF-8"?>

 <!--basedir是从build.xml所在的目录为基础算起的-->
<project name="acm-rest-service" default="copy" basedir="../../../"> <!--定义常用目录属性-->
<property name="encoding" value="UTF-8" />
<property name="deploy.name" value="acm-rest-service" />
<property name="src.dir" value="${basedir}/SourceCode/JavaSource/mulms/cn/com/infosky/mulms/service/rest" />
<property name="lib.dir" value="${basedir}/SourceCode/JavaSource/lib" />
<property name="config.dir" value="${basedir}/Config/mulms/rest" />
<property name="target.dir" value="C:/deploy/mulms/${deploy.name}" />
<property name="output.web-inf.dir" value="${target.dir}/WEB-INF"/>
<property name="classes.dir" value="${output.web-inf.dir}/classes" />
<property name="output.lib.dir" value="${output.web-inf.dir}/lib" /> <!--编译时的classpath-->
<path id="classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path> <!--初始化,创建主要输出目录-->
<target name="init">
<mkdir dir="${target.dir}" />
<mkdir dir="${classes.dir}" />
<mkdir dir="${output.lib.dir}" />
</target> <!--清空输出内容-->
<target name="clean">
<delete includeEmptyDirs="true" dir="${target.dir}" />
</target> <!-- 编译 -->
<target name="compile" depends="init">
<javac srcdir="${src.dir}" destdir="${classes.dir}" debug="true" encoding="${encoding}" includeantruntime="false">
<classpath refid="classpath" />
</javac>
</target> <!--复制相应的文件-->
<target name="copy" depends="clean,compile"> <!--将所有依赖的jar文件复制到web-inf/lib目录下-->
<copy todir="${output.lib.dir}" overwrite="yes" flatten="true">
<fileset dir="${lib.dir}/jsr-rs">
<include name="**/*.jar" />
</fileset>
</copy> <!--将web.xml复制到web-inf下-->
<copy todir="${output.web-inf.dir}" overwrite="yes" flatten="true">
<fileset dir="${config.dir}">
<include name="**/*.xml" />
</fileset>
</copy>
</target> <!--生成war包-->
<target name="webwar" depends="copy">
<war webxml="${output.web-inf.dir}/web.xml" destfile="${target.dir}/../${deploy.name}.war">
<fileset dir="${target.dir}/">
<include name="**/*.*" />
</fileset>
</war>
</target>
</project>
上一篇:Python学习笔记之将数据写入到文件中


下一篇:【Swift学习】Swift编程之旅---继承(十七)