【问题标题】:Passing system properties along with proguard configuration file to gradle proguardFile property将系统属性与 proguard 配置文件一起传递给 gradle proguardFile 属性
【发布时间】:2019-12-08 21:54:27
【问题描述】:

我正在尝试在我的 gradle 项目中调用 proguard。

方法1:

使用 ant.java 并传递 proguard.jar 及其配置,如下所示

    ant.java(jar:"c:/proguard5.1/lib/proguard.jar",fork:true){
     arg(value: "@./proguardconf-splitjars.pro")
     sysproperty( key : "jar.dir",value : "codegen/libs")                
     sysproperty( key : "target",value : "android-28")               
     sysproperty( key : "sdk.dir",value : "C:\\android-sdk-windows")                 
    } 

方法二:

在 gradle 文件中使用 proguardFile 属性,如 https://developer.android.com/studio/build/shrink-code.html 中所述

buildTypes {
     debug {
        minifyEnabled true
        proguardFile 'proguardconf-splitjars.pro'
    }
   }

我在 proguard 文件中有不同的属性变量,我必须在调用 proguard 时传递它们。我能够传递属性并使用 Approach1 调用 proguard。

有没有什么方法可以通过 Approach2 传递属性变量。我参考了下面的链接,但没有找到任何与我的要求相关的信息。

https://www.guardsquare.com/en/products/proguard/manual/gradle https://developer.android.com/studio/build/shrink-code.html

【问题讨论】:

    标签: android android-gradle-plugin build.gradle proguard


    【解决方案1】:

    Gradle 支持设置系统属性的不同方式。对我来说,最方便的方法是在 gradle.properties 文件中指定它们,如下所示:

    systemProp.jar.dir=codegen/libs

    例如,对于您的 ant 示例中的属性之一。

    另见Gradle documentation

    【讨论】:

      猜你喜欢
      • 2013-03-24
      • 2015-06-30
      • 1970-01-01
      • 1970-01-01
      • 2017-02-10
      • 2019-01-31
      • 2015-03-18
      • 1970-01-01
      相关资源
      最近更新 更多