Skip to content

ProGuard Maven plugin with improved support for WAR file processing

License

Notifications You must be signed in to change notification settings

radomirml/proguard-maven-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ProGuard Maven Plugin (with WAR support)

This project is a fork of wvengen's proguard maven plugin with focus on easier war file processing with ProGuard.

If plugin's input jar is a war file, the plugin uses the following workflow:

  1. The war file is extracted to a temporary directory (in build directory, with _'war_proguard_expanded' appended to base war file name)
  2. Artifacts referenced by assembly inclusions section (with wildcard supported for artifactId) are used as ProGuard injars. All other artifacts are used as libraryjars. Input artifacts files that exist in WEB-INF/lib, are referenced using that location rather than location within user's maven repository.
  3. Proguarded classes and resources will be out to a jar file in WEB-INF/lib named by the artifact. Processed input jars located in WEB-INF/lib are deleted.
  4. If processWarClassesDir option is enabled, WEB-INF/classes will be processed as injars and output separately (to replace existing WEB-INF/classes directory).
  5. Finally, output war archive is created.

Additional configuration parameters supported:

  • processWarClassesDir - if enabled, WEB-INF/classes will be processed as injars
  • attachMap - whether or not to attach proguard map file as an artifact
  • attachMapArtifactType - defaults to txt
  • attachMapArtifactClassifier - defaults to proguard-map
  • attachSeed - whether or not to attach proguard seed file as an artifact
  • attachSeedArtifactType - defaults to txt
  • attachSeedArtifactClassifier - defaults to proguard-seed

Configuration example for war

<plugin>
  <groupId>com.github.radomirml</groupId>
  <artifactId>proguard-maven-plugin</artifactId>
  <version>2.0.9</version>
  <executions>
    <execution>
      <phase>package</phase>
      <goals>
        <goal>proguard</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <proguardVersion>4.8</proguardVersion>
    <obfuscate>true</obfuscate>
    <maxMemory>1024m</maxMemory>
    <includeDependency>true</includeDependency>
    <processWarClassesDir>true</processWarClassesDir>
    <options>    
      <option>-ignorewarnings</option>  
      <option>-repackageclasses xyz</option>
      <option>-dontoptimize</option>
    </options>
    <assembly>
      <inclusions>
        <inclusion>
          <groupId>${project.groupId}</groupId><artifactId>*</artifactId>
        </inclusion>
      </inclusions>
    </assembly>
    <exclusions>
      <exclusion>
        <groupId>commons-logging</groupId><artifactId>*</artifactId>
      </exclusion>
      <exclusion>
        <groupId>log4j</groupId><artifactId>*</artifactId>
      </exclusion>
    </exclusions>
    <injar>${project.build.finalName}.war</injar>
    <!--<outjar>${project.build.finalName}-proguarded.war</outjar> - not required (proguarded added by default) -->
    <outputDirectory>${project.build.directory}</outputDirectory>    
    <attach>true</attach>
    <appendClassifier>true</appendClassifier>
    <attachArtifactClassifier>proguarded</attachArtifactClassifier>
    <attachArtifactType>war</attachArtifactType>
    <attachMap>true</attachMap>
    <attachSeed>true</attachSeed>
    <proguardInclude>${basedir}/proguard.conf</proguardInclude>
    <libs>
      <lib>${java.home}/lib/rt.jar</lib>
    </libs>
    <addMavenDescriptor>false</addMavenDescriptor>
    <skip>false</skip>
  </configuration>
</plugin>

Base project description

Run ProGuard as part of your Maven build. For usage, please read the generated Documentation.

Development happens at Github. This plugin is currently not under active development, but pull requests are welcome.

This is the successor of the ProGuard Maven Plugin by pyx4me.

Build Status Maven Central

About

ProGuard Maven plugin with improved support for WAR file processing

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 95.9%
  • Shell 2.9%
  • Groovy 1.2%