Maven, Proguard and the jar I don't want

I cover the project with proguard-maven-plugin. Everything works fine, except for one: I do not want the original jar, neither in the target directory, nor deployed in the repository. At the moment, I get a jar of orignal and a blurred jar. Leaving this this way will cause problems in our builds server, as both artifacts will be deployed, which will lead to duplication of interfaces in the classpath. Using a blacklist on a builds server is not an option.

Any idea?

Thanks!

+4
source share
4 answers

According to the documentation for the Proguard plugin in Maven, if you do not specify the outjar parameter, it will override the input jar.

http://pyx4me.com/pyx4me-maven-plugins/proguard-maven-plugin/proguard-mojo.html

+1
source

You just need to specify the injar and outjar parameter specified on the same bank, proguard will override the original bank.

My proguard setup (this parameter is for java 6, for java 7, change groupid, artifactid and version accordingly):

<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> 

NTN.

0
source

Setting the attach configuration parameter to true seems to replace the original project artifact.

http://pyx4me.com/pyx4me-maven-plugins/proguard-maven-plugin/proguard-mojo.html#attach

0
source

If anyone has this problem, the following configuration works for me. This renames the original jar to {final name} _proguard_base.jar and redefines the project container with the processed 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> 
0
source

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


All Articles