如何将 Gradle Proguard 插件用作 Maven 存储库依赖项? (不引用本地文件夹。)
How to use the Gradle Proguard Plugin as a Maven repository dependency? (Without referencing local folders.)
为了使用 Proguard 的 gradle 插件,使用 Proguard Gradle manual 中介绍的方法必须手动下载 Proguard 并将其放在本地文件夹中。特别是手册说:
One way is to add the following line to your build.gradle file
并且手册提供了以下内容build.gradle
buildscript {
repositories {
flatDir dirs: '/usr/local/java/proguard/lib'
}
dependencies {
classpath ':proguard:'
}
}
值得注意的是,这只是'One way'添加了proguard。
可以通过将路径定义为变量来使其更加参数化,以便轻松地从一个混淆器构建迁移到另一个构建,但它不是那么可移植。
需要的是使用混淆器而无需配置程序员的工作区,最好从 Maven 存储库下载混淆器。
在 CI(例如 Jenkins)中构建项目或在不同环境中使用项目等情况下,这可以节省时间并减少错误。
我想出了以下 gradle 脚本:
// Tell Gradle where to find the ProGuard task.
buildscript {
repositories {
mavenLocal() //in case it is already downloaded
mavenCentral()
}//end repositories
dependencies { classpath 'net.sf.proguard:proguard-gradle:6.0.3' }
}//end buildscript
这种方法工作正常,使用存储库中的混淆器似乎没问题。 See also in sourceforge.
理由:“/usr/local/java/proguard/lib”文件夹仅包含 proguard 的 jar,使用 proguard-gradle 作为依赖项还将获取所需的其他依赖项。
为了使用 Proguard 的 gradle 插件,使用 Proguard Gradle manual 中介绍的方法必须手动下载 Proguard 并将其放在本地文件夹中。特别是手册说:
One way is to add the following line to your build.gradle file
并且手册提供了以下内容build.gradle
buildscript {
repositories {
flatDir dirs: '/usr/local/java/proguard/lib'
}
dependencies {
classpath ':proguard:'
}
}
值得注意的是,这只是'One way'添加了proguard。 可以通过将路径定义为变量来使其更加参数化,以便轻松地从一个混淆器构建迁移到另一个构建,但它不是那么可移植。
需要的是使用混淆器而无需配置程序员的工作区,最好从 Maven 存储库下载混淆器。 在 CI(例如 Jenkins)中构建项目或在不同环境中使用项目等情况下,这可以节省时间并减少错误。
我想出了以下 gradle 脚本:
// Tell Gradle where to find the ProGuard task.
buildscript {
repositories {
mavenLocal() //in case it is already downloaded
mavenCentral()
}//end repositories
dependencies { classpath 'net.sf.proguard:proguard-gradle:6.0.3' }
}//end buildscript
这种方法工作正常,使用存储库中的混淆器似乎没问题。 See also in sourceforge.
理由:“/usr/local/java/proguard/lib”文件夹仅包含 proguard 的 jar,使用 proguard-gradle 作为依赖项还将获取所需的其他依赖项。