栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Java:如何使用自定义Ant build.xml将ProGuard集成到Jar项目中

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Java:如何使用自定义Ant build.xml将ProGuard集成到Jar项目中

我发现了几种集成方式,但这是最简单的方式。

<?xml version="1.0" ?><project name="Samples" default="dist" basedir=".">    <!-- generate JAR START -->    <description>Samples Library</description>    <!-- Setting global properties for this build -->    <property name="src" location="src" />    <property name="bin" location="bin" />    <target name="dist">        <jar destfile="Samples.jar" basedir="bin/"> <!-- Use ** to include the directory recursively --> <include name="com/samples/**" />        </jar>    </target>    <!-- generate JAR END -->    <!-- The local.properties file is created and updated by the 'android'         tool.         It contains the path to the SDK. It should *NOT* be checked into         Version Control Systems. -->    <property file="local.properties" />    <!-- The build.properties file can be created by you and is never touched         by the 'android' tool. This is the place to change some of the         default property values used by the Ant rules.         Here are some properties you may want to change/update:         source.dir  The name of the source directory. Default is 'src'.         out.dir  The name of the output directory. Default is 'bin'.         Properties related to the SDK location or the project target should         be updated using the 'android' tool with the 'update' action.         This file is an integral part of the build system for your         application and should be checked into Version Control Systems.         -->    <property file="build.properties" />    <!-- The default.properties file is created and updated by the 'android'         tool, as well as ADT.         This file is an integral part of the build system for your         application and should be checked into Version Control Systems. -->    <property file="default.properties" />    <!-- Add Proguard Tasks -->    <property name="proguard.jar" location="proguard/lib/proguard.jar" />    <taskdef resource="proguard/ant/task.properties"         classpath="${proguard.jar}" />    <proguard configuration="proguard.cfg"/></project>

这是 proguard.cfg

-injars       Samples.jar-outjars      Samples-out.jar-libraryjars  libs/android.jar-printmapping out.map-renamesourcefileattribute SourceFile-keepattributes Exceptions,InnerClasses,Signature,Deprecated,     SourceFile,LineNumberTable,*Annotation*,EnclosingMethod-keep public class * {    public protected *;}-keepclassmembernames class * {    java.lang.Class class$(java.lang.String);    java.lang.Class class$(java.lang.String, boolean);}-keepclasseswithmembernames class * {    native <methods>;}-keepclassmembers enum * {    public static **[] values();    public static ** valueOf(java.lang.String);}-keepclassmembers class * implements java.io.Serializable {    static final long serialVersionUID;    private static final java.io.ObjectStreamField[] serialPersistentFields;    private void writeObject(java.io.ObjectOutputStream);    private void readObject(java.io.ObjectInputStream);    java.lang.Object writeReplace();    java.lang.Object readResolve();}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/515675.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号