如何为我的Java Gradle应用程序使用proguard代码创建已废弃的jar

问题描述

我正在使用6.4.1,而我的gradle应用程序是一个多模块项目。我需要生成要混淆的罐子。我在build.gradle中使用了以下任务,但它在指定位置生成了jar,但没有混淆。

如何实现对瓶子的迷惑?这里缺少什么?请对此提供任何想法。

build.gradle,

    buildscript {
    repositories {
        mavenLocal()
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.guardsquare:proguard-gradle:7.0.0'
    }
}
allprojects {

    apply plugin: 'java'
// my dependencies configuration here
}
task proguard(type: proguard.gradle.ProGuardTask) {
    description 'Optimizes and obfuscates the created distribution jar.'
    verbose
    dontwarn

    injars  'mypath/build/libs/myjar-1.0.jar'
    outjars 'mypath/build/libs/myjar-1.0-obfs.jar'

    if (System.getProperty('java.version').startsWith('1.')) {
        libraryjars "${System.getProperty('java.home')}/lib/rt.jar"
    } else {
        libraryjars "${System.getProperty('java.home')}/jmods/java.base.jmod",jarfilter: '!**.jar',filter: '!module-info.class'
    }
    libraryjars configurations.findByName('runtimeClasspath').getFiles()

    printmapping 'out.map'

    keep 'public class * { \
        public protected *; \
    }'

    keepclassmembers allowoptimization: true,'enum * { \
        public static **[] values(); \
        public static ** valueOf(java.lang.String); \
    }'

    keepclassmembers 'class * implements java.io.Serializable { \
        static final long serialVersionUID; \
        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(); \
     }'

     overloadaggressively
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)