我用proguard-maven-plugin阻止了一个项目。一切正常,除了一件事:我不想要原始jar,既不在目标目录中也不在存储库中部署。此刻,我得到了原始罐子和装满罐子的罐子。以这种方式离开会导致我们的构建服务器出现问题,因为两个工件都将被部署,导致类路径中出现重复的接口。在buildserver上使用黑名单不是一种选择。
有什么想法吗?
谢谢!
答案 0 :(得分:1)
根据Maven中Proguard插件的文档,如果你没有指定一个outjar参数,它将覆盖输入jar。
http://pyx4me.com/pyx4me-maven-plugins/proguard-maven-plugin/proguard-mojo.html
答案 1 :(得分:1)
你只需指定指向同一个jar的injar和outjar参数,proguard将覆盖原来的jar。
我的proguard设置(java 6的此设置,对于java 7,相应地更改groupid,artifactid和版本):
<plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<obfuscate>true</obfuscate>
<includeDependency>false</includeDependency>
<injar>classes</injar>
<maxMemory>512m</maxMemory>
<libs>
<!-- dependency jar here -->
</libs>
<options>
<option>-keepattributes *Annotation*</option>
<option>-allowaccessmodification</option>
<option>-dontskipnonpubliclibraryclasses</option>
<option>-dontskipnonpubliclibraryclassmembers</option>
<option>-dontusemixedcaseclassnames</option>
<option>-dontshrink </option>
</options>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard</artifactId>
<version>4.4</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
HTH。
答案 2 :(得分:1)
如果有人遇到此问题,以下配置对我有用。这会将原始jar重命名为{final name} _proguard_base.jar,并使用已处理的jar覆盖项目jar。
<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>
<configuration>
<proguardVersion>${proguard.version}</proguardVersion>
<obfuscate>false</obfuscate>
<injarNotExistsSkip>true</injarNotExistsSkip>
<injar>${project.build.finalName}.jar</injar>
<outputDirectory>${project.build.directory}</outputDirectory>
<addMavenDescriptor>true</addMavenDescriptor>
<attach>false</attach>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
<lib>${java.home}/lib/jsse.jar</lib>
<lib>${java.home}/lib/jce.jar</lib>
</libs>
<proguardInclude>${project.basedir}/proguard.conf</proguardInclude>
<options>
<option>-printseeds ${project.build.directory}/proguard-seeds.txt</option>
<option>-printusage ${project.build.directory}/proguard-shrinkusage.txt</option>
<option>-printmapping ${project.build.directory}/proguard-mapping.txt</option>
<option>-printconfiguration ${project.build.directory}/proguard-config.txt</option>
<option>-dontobfuscate</option>
<option>-keepdirectories</option>
<option>-dontskipnonpubliclibraryclasses</option>
<option>-dontskipnonpubliclibraryclassmembers</option>
</options>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>${proguard.version}</version>
</dependency>
</dependencies>
</plugin>
答案 3 :(得分:0)
将配置选项attach
设置为true似乎替换了原始项目工件。
http://pyx4me.com/pyx4me-maven-plugins/proguard-maven-plugin/proguard-mojo.html#attach