Maven with Proguard and installation plugin

I am trying to use Maven with the following configuration:

  • Use the maven-assembly-plugin to create a single JAR with all the dependencies (build: single).
  • Then use the Proguard plugin to trim all unnecessary classes from the included libraries.

I need proguard to reduce dependency size. The OpenIMAJ library that I use is huge (100 MB), and I only need a small subset of it.

The problem is that my current Maven configuration launches plugins in the opposite order - Proguard launches first and creates JARs without dependencies.

The plugin section of my pom.xml:

<plugins> <plugin> <groupId>com.github.wvengen</groupId> <artifactId>proguard-maven-plugin</artifactId> <version>2.0.6</version> <executions> <execution> <phase>package</phase> <goals><goal>proguard</goal></goals> </execution> </executions> <dependencies> <dependency> <groupId>net.sf.proguard</groupId> <artifactId>proguard-base</artifactId> <version>4.9</version> <scope>runtime</scope> </dependency> </dependencies> <configuration> <proguardVersion>4.9</proguardVersion> <options> <option>-verbose</option> <option>-dontobfuscate</option> <option>-dontoptimize</option> <option>-keep class org.apache.** { *; }</option> <option>-keep class no.** { *; }</option> </options> <libs> <lib>${java.home}/lib/rt.jar</lib> <lib>${java.home}/lib/jsse.jar</lib> </libs> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>fully.qualified.MainClass</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> <executions> <execution> <id>make-assembly</id> <!-- this is used for inheritance merges --> <phase>package</phase> <!-- bind to the packaging phase --> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> 
+6
source share
1 answer

Both plugins are configured to run in the package phase. Therefore, I think Maven will execute them in the order in which they are defined in pom. (Apparently, since Maven 3.0.3: http://www.mkyong.com/maven/maven-plugin-execution-order-in-same-phase/ )

Have you tried to determine their order?

If this does not work, you should probably try to run the build plugin during the prepare-package phase.

However, my answer is only for the order, I'm not sure if this will help you with all the cutting thing.

0
source

Source: https://habr.com/ru/post/946214/


All Articles