Include proguard config file in pom.xml

I am trying to obfuscate Java class files. I've used ant before, so I managed to confuse them during the build process by including the 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 the proguard configuration file. Now I am trying to do the same with maven. I am learning maven so I have no idea how to do the same in "pom.xml". Thank you and sorry for the bad english.

+3


source to share


2 answers


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

      



+6


source


The project I was using no longer exists here. It was just a temporary test project. We decided not to use Proguard after all.



However, I used proguard-maven-plugin and created my POM according to its Usage section in conjunction with ProGuard .

0


source







All Articles