Ant是一种基于Java的build工具,类似于c语言中的makefile,这里做一记录,方便后面查看。
<?xml version="1.0" encoding="UTF-8"?> <project name="vailidategame" default="yguard" basedir="."> <property name="src" value="${basedir}/src" /> <property name="lib" value="${basedir}/lib" /> <property name="build" value="${basedir}/build" /> <property name="build.class" value="${build}/classes" /> <property name="app.name" value="FrameWork" /> <property name="app.jar" value="${app.name}.jar" /> <property name="obfuscationlog" value="${build}"/> <property name="obf.jar" value="${app.name}_obf.jar" /> <property name="obfjarpath" value="${basedir}/lib"/> <property name="shrinklog" value="${project_name}_shrinklog.xml"/> <property name="renamelog" value="${project_name}_renamelog.xml"/> <!--请将下面的路径改为你本地的路径--> <property name="webserver" value="D:uild-tomcatwebapps" /> <!--定义CLASSPACH,编译时用到你外部加入的包--> <!-- <path id="classpath"> <pathelement location="${src}" /> <fileset dir="${lib}" includes="***.jar" /> </path> --> <!--删除任务--> <target name="clean" description="删除"> <echo message="删除目录" /> <delete dir="${build}" /> </target> <!--创建一个临时目录--> <target name="init" description="创建目录" depends="clean"> <echo message="创建目录--以执行" /> <mkdir dir="${build.class}" /> </target> <!-- 编译 --> <target name="compile" description="开始编译" depends="init"> <echo message="生成jar开始……" /> <javac srcdir="src" destdir="${build.class}"> <!-- <classpath> <fileset dir="lib"> <include name="**/*.jar"/> </fileset> </classpath> --> </javac> </target> <!-- 打成jar包 --> <target name="generjar" description="打包" depends="compile"> <echo message="打成jar包"/> <jar jarfile="${build}/${app.jar}" basedir="${build.class}"> <!-- <manifest> <attribute name="Main-Class" value="bean.ant.TestAnt" /> </manifest> --> </jar> </target> <!-- 混淆任务 --> <!-- <target name="yguard" depends="generjar"> <echo message="开始混淆"/> <taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="yguard.jar" /> <echo message="产生混淆文件"/> <yguard> <inoutpair in="${build}/${app.jar}" out="${build}/${obf.jar}"/> </yguard> </target> --> <target depends="generjar" name="yguard"> <taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="yguard.jar"/> <!-- the following can be adjusted to your needs --> <yguard> <inoutpair in="${build}/${app.jar}" out="${build}/${obf.jar}"/> <shrink logfile="${shrinklog}"> <keep> <class classes="protected" methods="protected" fields="protected"> <patternset> <include name="com.subao.validate.**.*"/> <!-- <exclude name="com.subao.validate.http.**.*"/> --> </patternset> </class> </keep> </shrink> <rename logfile="${renamelog}"> <property name="error-checking" value="pedantic"/> <keep> <class classes="protected" methods="protected" fields="protected"> <patternset> <include name="com.subao.validate.**.*"/> <!-- <exclude name="com.subao.validate.http.**.*"/> --> <exclude name="com.subao.validate.entity.**.*"/> </patternset> </class> </keep> </rename> </yguard> </target> </project>大概解释一下:
1、上面project标签中的default代表默认执行的入口, basedir代表基准路径。
2、property标签定义变量。
3、target标签中就分别是相应的操作。
相关资源:
yguard混淆:http://download.csdn.net/detail/lxq_xsyu/8149559
jar包混淆工具:http://download.csdn.net/detail/lxq_xsyu/8149539
jar包反编译工具:http://download.csdn.net/detail/lxq_xsyu/8149513
这些工具用起来都特别简单,相关界面截图如下: