[英]Maven with Proguard and assembly plugin
I am trying to use Maven with the following configuration: 我正在尝试使用以下配置的Maven:
I need proguard to shrink the size of the dependencies. 我需要proguard来缩小依赖项的大小。 The OpenIMAJ library I'm using is huge (100MB), and I only need a small subset of it. 我正在使用的OpenIMAJ库是巨大的(100MB),我只需要它的一小部分。
The problem is that my current Maven config runs the plugins in opposite order - Proguard runs first and builds a JAR without the dependencies. 问题是我当前的Maven配置以相反的顺序运行插件 - Proguard首先运行并构建一个没有依赖项的JAR。
Plugin section of my pom.xml: 我的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>
Both plugin are configured to be executed on the package
phase. 两个插件都配置为在package
阶段执行。 Therefore, I think Maven will execute them in the order they are defined in the pom. 因此,我认为Maven将按照它们在pom中定义的顺序执行它们。 (Apparently so, since Maven 3.0.3: http://www.mkyong.com/maven/maven-plugin-execution-order-in-same-phase/ ) (显然是这样,因为Maven 3.0.3: http ://www.mkyong.com/maven/maven-plugin-execution-order-in-same-phase/)
Did you try to define them the order way around? 您是否尝试按顺序定义它们?
If it doesn't work, you should probably try to run the assembly plugin during the prepare-package
phase. 如果它不起作用,您可能应该尝试在prepare-package
阶段运行程序集插件。
However, my answer only worth for the ordering, I'm not sure if that will help you with the whole shrinking thing. 但是,我的答案只值得订购,我不确定这是否会帮助你完成整个缩小的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.