In order to use the gradle plugin of Proguard, using the method presented in the Proguard Gradle manual one has to manually download Proguard and place it in a local folder. In particular the manual says:
One way is to add the following line to your build.gradle file
And the manual provides the following build.gradle
buildscript {
repositories {
flatDir dirs: '/usr/local/java/proguard/lib'
}
dependencies {
classpath ':proguard:'
}
}
It is worth noticing that this is just 'One way' to add the proguard. It can be made more parameterized by defining the path as a variable for easy migration from one proguard build to another but it is not so portable.
What is needed is to use proguard without having to configure the workspace of the programmer, preferable having proguard downloaded from a Maven repository. This can save time and reduce errors in cases such as building the project in a CI (e.g. Jenkins) or if the project is used in different environments.
I came up with the following gradle script:
// 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
This approach is working OK and using proguard from the repositories seems to be fine. See also in sourceforge.
Justification: The '/usr/local/java/proguard/lib' folder contains just the jars of proguard, using the proguard-gradle as a dependency will fetch also other dependencies required.