yguard代码混淆例子(原创)
<?xml version="1.0" encoding="UTF-8"?>
<project name="project" default="yguard" basedir=".">
<target name="init">
<property name="project_name" value="3D"/>
<property name="srcDir" value="src"/>
<property name="classDir" value="classes"/>
<property name="libDir" value="lib"/>
<property name="jar" value="${project_name}.jar"/>
<property name="obfjar" value="${project_name}_obf.jar"/>
<property name="mainclass" value="cs.Main"/>
<mkdir dir="${classDir}"/>
</target>
<target depends="jar" name="yguard">
<taskdef name="yguard"
classname="com.yworks.yguard.YGuardTask"
classpath="yguard.jar"/>
<yguard>
<externalclasses>
<pathelement location="lib/1.jar"/>
<pathelement location="lib/2.jar"/>
<pathelement location="lib/3.jar"/>
</externalclasses>
<inoutpair in="${jar}" out="${obfjar}"/>
<rename mainvalue="pedantic"/>
<map>
<package name="cs.A" map="1"/>
<package name="cs.B" map="2"/>
<package name="cs.C" map="3"/>
<package name="cs.D" map="4"/>
<package name="cs.E" map="5"/>
<package name="cs.F" map="6"/>
<package name="cs.G" map="7"/>
<package name="cs.H" map="8"/>
<package name="cs.I" map="9"/>
<package name="cs.J" map="10"/>
</map>
</rename>
</yguard>
</target>
<target name="compile" depends="init">
<javac srcdir="${srcDir}"
includes="**/*.java"
destdir="${classDir}"
extdirs="${libDir}">
</javac>
</target>
<target name="jar" depends="compile">
<manifest file="MANIFEST.MF">
<attribute name="Main-Class"
value="cs.Main"/>
<attribute name="Class-Path"
value="lib/ABCD.jar"/>
</manifest>
<jar jarfile="${jar}"
basedir="${classDir}"
includes="**/*.class"
manifest="MANIFEST.MF">
<fileset dir="${srcDir}">
<include name="cs/ABC/*.png"/>
</fileset>
</jar>
</target>
<target name="run" depends="yguard">
<java classname="${mainclass}" fork="true">
<classpath>
<pathelement location="${obfjar}"/>
</classpath>
</java>
</target>
</project>