Ant 随想
Ant是一种基于Java的build工具
面向任务构建,属性与于shell脚本中命令功能类型。
<?xml version="1.0"?> <project name="Product-Release" default="compile" basedir="."> <!-- 定义编译classes目录 --> <property name="classes.dir" value="./WebRoot/WEB-INF/classes" /> <!-- 定义源文件src目录 --> <property name="src.dir" value="./src" /> <!--定义所有引用的jar包--> <path id="all-libs"> <fileset dir="./lib"> <include name="**/*.jar" /> </fileset> </path> <!-- 使用说明--> <target name="usage"> <echo message="" /> <echo message="Product build script" /> <echo message="-----------------------------------------" /> <echo message="" /> <echo message="Among the available targets are:" /> <echo message="" /> <echo message="release --> make tomcat run" /> <echo message=""/> </target> <!--清理classes目录--> <target name="clean" description="Clean all classes dir"> <delete dir="${classes.dir}" /> </target> <!--编译工程--> <target name="compile" depends="clean" description="Compile source files into class files"> <mkdir dir="${classes.dir}" /> <javac destdir="${classes.dir}" encoding="utf-8" source="1.5" target="1.5" debug="${javac.debug}" deprecation="false" optimize="false" failonerror="true"> <src path="${src.dir}" /> <classpath refid="all-libs" /> </javac> </target> <target name="zipMend" description="补丁zip包">
<mkdir dir="MAGAZINE_Mend" />
<delete dir="MAGAZINE_Mend/magazineSP_1017.zip" />
<!-- 输出文件,及相对搜索路径 -->
<zip destfile="MAGAZINE_Mend/magazineSP_1030.zip" basedir="WebRoot/">
<!-- 需要打入补丁中的Class文件-->
<include name="WEB-INF/classes/com/bokeyuan/magazine/support/ContentFile/ContentFile.class" />
<include name="WEB-INF/classes/com/cc/**/*.class" />
</zip>
</target> </project>
depends:依赖前个任务 target:任务
javac:编译 mkdir:生成文件夹
echo:打印 zip:zip包
include:包含 destfile:zip输出文件夹
Stay Hungry,Stay Foolish!