ProGuard 应用Gradle Task

本文介绍了如何在Gradle 2.1及以上版本中将ProGuard作为一个任务运行,强调了确保Gradle在构建时能找到ProGuard的重要性,并展示了如何在build.gradle文件中配置。同时,提到了ProGuard任务的配置文件设置和injars class_path选项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ProGuard can be run as a task in the Java-based build tool Gradle (version 2.1 or higher).

ProGuard可以作为一个任务运行在基于java的构建工具Gradle(版本2.1或更高版本)。

Before you can use the proguard task, you have to make sure Gradle can find it in its class path at build time. One way is to add the following line to your build.gradle file:

您可以使用ProGuard 之前,您必须确保它可以找到它在构建时的类路径。一种方法是添加 build.gradle 文件

buildscript {
    repositories {
        flatDir dirs: '/usr/local/java/proguard/lib'
    }
    dependencies {
        classpath ':proguard:'
    }
}

Please make sure the class path is set correctly for your system.

请确保您的系统类路径设置正确。

You can then define a task:

你可以定义一个task

task myProguardTask(type: proguard.gradle.ProGuardTask) {
    .....
}

The embedded configuration is much like a standard ProGuard configuration. Notable similarities and differences:

嵌入的配置是更像一个标准ProGuard 配置。明显的异同

  • Like in ProGuard-style configurations, we’re using all lower-case names for the settings.
  • The options don’t have a dash as prefix.
  • Arguments typically have quotes.
  • Some settings are specified as named arguments.

    • 像ProGuard的配置,我们使用所有小写名称的设置
    • 选项没有前缀
    • 参数通常有引用
    • 一些设置指定为命名参数

You can find some sample build files in the examples/gradle directory of the ProGuard distribution.

你可以在examples/ gradle 目录下找到一些ProGuard 描述的示例构建文件

Setting

The ProGuard task supports the following settings in its closure:
ProGuard 任务支持以下设置

configuration files
  • Read and merge options from the given ProGuard-style configuration files. The files are resolved and parsed lazily, during the execution phase.

从给定的ProGuard-style阅读和合并选项配置文件。文件在执行阶段解析

injars class_path

未完待续

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值