<!
使用${programName}替換掉屬性文件GENproperties中的@PROGRAMNAME@
>
<replace file=GENproperties
token=@PROGRAMNAME@
value=${programName}
/>
<!
使用GENproperties文件中的屬性值替換掉模板文件MANIFESTtmp中的對應屬性值
將替換後的數據復制到${srcdir}\MANIFESTMF
>
<copy file=MANIFESTtmp
tofile=${srcdir}\MANIFESTMF>
<filterset begintoken=@ endtoken=@>
<filtersfile file=GENproperties/>
</filterset>
</copy>
</target>
<target name=package description=將class打包輸出到${packagedir}>
<echo message=將class打包輸出到${packagedir}/>
<jar basedir=${preverifiednoObfusedClassdir}
jarfile=${packagedir}\${programName}noObfusedjar
manifest=${srcdir}\MANIFESTMF >
<fileset dir=${resdir} includes=**/*png/>
</jar>
</target>
<target name=obfuscate description=對打包後的jar文件進行混淆然後解壓縮至${packageextractdir}> <echo message=對打包後的jar文件進行混淆然後解壓縮至${packageextractdir}/>
<java fork=true classname=proguardProGuard>
<classpath path=${proguardlibdir}\proguardjar/>
<arg line=libraryjars ${midplibpath}/>
<arg line=injar ${packagedir}\${programName}noObfusedjar/>
<arg line=outjar ${packagedir}\${programName}obfusedjar/>
<!保留MIDlet的類聲明不被混淆>
<arg line=keep public class * extends javaxmicroeditionmidletMIDlet/>
<!打印被保留的類名>
<arg line=printseeds/>
</java>
<unjar src=${packagedir}\${programName}obfusedjar
dest=${packageextractdir} />
</target>
<target name=verifyForObfuscate description=驗證被混淆的class輸出到${preverifiedobfusedClassdir}>
<echo message=驗證被混淆的class輸出到${preverifiedobfusedClassdir}/> <exec executable=${preverifybin} searchpath=false>
<arg line=classpath ${midplibpath}/>
<arg line=d ${preverifiedobfusedClassdir}/>
<arg line=${packageextractdir}/>
</exec>
<copy todir=${preverifiedobfusedClassdir}>
<fileset dir=${packageextractdir} includes=**/*png/>
</copy>
</target>
<target name=deploy description=將經過驗證的混淆後的class打包部署在delpoy目錄>
<echo message=將經過驗證的混淆後的class打包部署在${deploydir}目錄/>
<jar basedir=${preverifiedobfusedClassdir}
jarfile=${deploydir}\${programName}jar
manifest=${srcdir}\MANIFESTMF
>
<fileset dir=${preverifiedobfusedClassdir} includes=**/*class;*png/>
</jar>
</target>
<target name=genJad description=在${deploydir}目錄生成JAD文件>
<echo message=在${deploydir}目錄生成JAD文件/>
<length file=${deploydir}\${programName}jar property=jarsize/>
<echo message=獲得jar文件長度${jarsize}/>
<replace file=GENproperties
token=@JARSIZE@
value=${jarsize}
/>
<replace file=GENproperties
token=@PROGRAMNAME@
value=${programName}
/>
<copy file=JADtmp tofile=${deploydir}\${programName}jad>
<filterset begintoken=@ endtoken=@>
<filtersfile file=GENproperties/>
</filterset>
</copy>
</target>
[] [] [] []
From:http://tw.wingwit.com/Article/program/Java/ky/201311/29260.html