ProGuard can be run as a task in Gradle. 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 which will download ProGuard from Maven Central:
tasks.register('proguard', ProGuardTask) {
configuration file('proguard.pro')
injars(tasks.named('jar', Jar).flatMap { it.archiveFile })
// Automatically handle the Java version of this build.
if (System.getProperty('java.version').startsWith('1.')) {
// Before Java 9, the runtime classes were packaged in a single jar file.
libraryjars "${System.getProperty('java.home')}/lib/rt.jar"
} else {
// As of Java 9, the runtime classes are packaged in modular jmod files.
libraryjars "${System.getProperty('java.home')}/jmods/java.base.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
//libraryjars "${System.getProperty('java.home')}/jmods/....."
}
verbose
outjars(layout.buildDirectory.file("libs/${baseCoordinates}-minified.jar"))
}
The embedded configuration is much like a standard ProGuard
configuration. You can find more details on the Gradle setup page.
⨠Features
ProGuard works like an advanced optimizing compiler, removing unused classes,
fields, methods, and attributes, shortening identifiers, merging classes,
inlining methods, propagating constants, removing unused parameters, etc.
The optimizations typically reduce the size of an application by anything
between 20% and 90%. The reduction mostly depends on the size of external
libraries that ProGuard can remove in whole or in part.
The optimizations may also improve the performance of the application, by up
to 20%. For Java virtual machines on servers and desktops, the difference
generally isn't noticeable.
ProGuard can also remove logging code, from applications and their
libraries, without needing to change the source code â in fact,
without needing the source code at all!
The manual pages (markdown,
html) cover the features and usage of
ProGuard in detail.
đť Building ProGuard
Building ProGuard is easy - you'll just need a Java 8 JDK installed.
To build from source, clone a copy of the ProGuard repository and run the following command:
./gradlew assemble
The artifacts will be generated in the lib directory. You can then execute ProGuard using the
scripts in bin, for example:
bin/proguard.sh
You can publish the artifacts to your local Maven repository using:
./gradlew publishToMavenLocal
đ¤ Contributing
Contributions, issues and feature requests are welcome in both projects.
Feel free to check the issues page and the contributing
guide if you would like to contribute.
We found that com.guardsquare:proguard-ant demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Package last updated on 07 Oct 2025
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Socket Threat Research maps a rare inside look at OtterCookieâs npm-Vercel-GitHub chain, adding 197 malicious packages and evidence of North Korean operators.
Socket researchers identified a malicious Chrome extension that manipulates Raydium swaps to inject an undisclosed SOL transfer, quietly routing fees to an attacker wallet.