I am trying to obfuscate java class files. I was using ant before, so i managed to obfuscate them during build process itself by including following code in 'build.xml'.
<target name="-post-jfx-jar">
<!-- obfuscate and optimize by ProGuard -->
<taskdef resource="proguard/ant/task.properties" classpath="lib/proguard.jar" />
<proguard configuration="config.pro">
</proguard>
<move
file="${dist.jar.dir}/${ant.project.name}.jar"
tofile="${dist.jar}" verbose="true" overwrite="true" />
</target>
'config.pro' is proguard configuration file. Now i am trying to do same thing with maven. I am learning maven so i have no idea how to do same thing in 'pom.xml'. Thank you and sorry for bad English.
<plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<proguardVersion>5.0</proguardVersion>
<obfuscate>true</obfuscate>
<injar>${project.build.finalName}.jar</injar>
<outjar>${project.build.finalName}-small.jar</outjar>
<outputDirectory>${project.build.directory}</outputDirectory>
<proguardInclude>${basedir}/config.pro</proguardInclude>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
<lib>${java.home}/lib/jsse.jar</lib>
</libs>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard</artifactId>
<version>5.0</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
The project I had used it in doesn't seem to exist any longer here. It was just a temporary test project. We decided not to use Proguard eventually.
However, I used the proguard-maven-plugin and created my POM according to its Usage section in conjunction with the ProGuard manual.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.