Maven,Proguard和装配问题 [英] Maven, Proguard and assembly issues
问题描述
我正在努力让Maven与ProGuard合作。
I'm trying to get Maven working with ProGuard.
我想要实现的目标如下:
What I want to achieve is the following:
-
运行对我的源文件进行ProGuard并生成混淆类
Run ProGuard over my source files and produce obfuscated classes
创建一个引用主类的清单文件,以便我可以将其作为jar执行
Create a manifest file that references the main class so that I can execute it as a jar
解压缩所有相关的库jar并创建一个包含它们的巨大jar。此文件只应与.class和.xml文件联系。
Unpack all of the associated library jars and create one huge jar containing them all. This file should only contact .class and .xml files only.
将它们组装成包含各种README.txt文件的.zip和tar.gz文件等等on。
Assemble them into .zip and tar.gz files that include various README.txt files and so on.
到目前为止,我有这样的事情:
So far I've got something like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<configuration>
<archive>
<manifest>
<mainClass>com.class.path.MainClass</mainClass>
</manifest>
</archive>
<includes>
<include>**/*.class</include>
<include>**/*.xml</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<configuration>
<options>
<option>-allowaccessmodification</option>
</options>
<obfuscate>true</obfuscate>
<injar>classes</injar>
<outjar>${project.build.finalName}.jar</outjar>
<outputDirectory>${project.build.directory}</outputDirectory>
<proguardInclude>src/main/assembly/proguard.conf</proguardInclude>
<libs>
lib/rt.jar</lib>
</libs>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assembly</id>
<phase>package</phase>
<goals>
<goal>assembly</goal>
</goals>
<configuration>
<descriptors>
<descriptor>
src/main/assembly/bin.xml
</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
但我没有快乐。任何人都可以给我任何模糊的指示吗?
But I'm having no joy. Can anyone give me any vague pointers on this?
提前致谢,
Matt
Thanks in advance, Matt
推荐答案
以下是适用于我的配置
<plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<obfuscate>true</obfuscate>
<options>
<option>-allowaccessmodification</option>
<option>-keep public class com.class.path.MainClass { public *; public static *; }</option>
</options>
<injar>${project.build.finalName}.jar</injar>
<outjar>${project.build.finalName}-small.jar</outjar>
<outputDirectory>${project.build.directory}</outputDirectory>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
<lib>${java.home}/lib/jsse.jar</lib>
</libs>
<addMavenDescriptor>false</addMavenDescriptor>
</configuration>
</plugin>
最后一个jar是finalName-small.jar
The final jar is the finalName-small.jar
这篇关于Maven,Proguard和装配问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!