Menu

Home

Richard Sand

IDFC ProGuard Maven Plugin

This is a a maven plug-in to obfuscate project artifacts using ProGuard. ProGuard is an open-source obfuscator also available on SourceForge: http://proguard.sourceforge.net/.

General usage information can be found here: http://mavenproguard.sourceforge.net/obfuscate-mojo.html. Please read the description of each plugin parameter.

Here is an example of obfuscating the classes and several dependent jars inside a WAR project: [Example-war]

In addition to the parameter-based configuration, the plugin will autoamtically look for a ProGuard-style configuration file called ${basedir}/src/main/config/${project.artifactId}-maven.pro. Its a good idea to put all of your "-keep" and other project-specific ProGuard configuration in this file to be automatically referenced at launch.

Some of the more common ProGuard parameters, such as "keep, shrink, obfuscate, donwarn" etc. have corresponding plugin parameters. For other ProGuard configuration, use the options parameter to pass arbitrary name/value parameters to ProGuard.

The plugin has the notion of a "primary" input to be obfuscated. This is specified with the inputFile parameter. If not specified, this defaults to the typical output of the packaging phase, which is ${project.build.finalName}.${project.packaging}. However, if you are obfuscating before the packaging phase, you would typically want to set this to ${project.build.outputDirectory} instead to indicate the classes directory. If a relative path is specified, it will be relative to the base directory of the project.

Additional inputs to be obfuscated may be specified by inputArtifact, which specifies project dependencies to be obfuscated, and inputJarPath which specifies the local filesystem path to resources (directories, jar files, etc) to be obfuscated. Set the artifact names in coordinate String form, e.g. com.idfconnect.someproject:SomeLibrary to pull it from the project dependencies. The version does not need to be included in the String. The artifact must already be a resolved dependency in the project - the plugin will not attempt to resolve the artifact.

Dependent libraries needed on the classpath for ProGuard may be specified using the libraryArtifacts element. This provides a list of additional project artifacts, specified by coordinate Strings, e.g. javax.servlet:javax.servlet-api:3.0.1, to be included as
ProGuard libraryjars parameters. Here, the version must be included in the coordinates. The plugin will attempt to resolve the artifact, so the artifact need not be a dependency in the project.

Also note that by default all project resolved dependencies are already automatically added by the plugin and do not need to be explicitly configured with this parameter.

Apache Maven, Maven, Apache, the Apache feather logo, and the Apache Maven project logos are trademarks of The Apache Software Foundation.


Related

Wiki: Example-war

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.