ProGuard + Maven with Java 7

假装没事ソ 提交于 2019-12-02 19:13:44
Bernd S

I use the proguard-maven-plugin from com.github.wvengen. Note the different groupId. That way I can use the latest proguard-base artifact 5.0. Both are in Maven Central. Here's how the proguard-base portion in my pom.xml looks right now:

Parent pom.xml:

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.github.wvengen</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <version>2.0.8</version>
                <dependencies>
                    <dependency>
                        <groupId>net.sf.proguard</groupId>
                        <artifactId>proguard-base</artifactId>
                        <version>5.0</version>
                        <scope>runtime</scope>
                    </dependency>
                </dependencies>
            </plugin>
[...]

Here's the rest from my child pom.xml, but you probably want to modify that:

 <build>
    <plugins>
        <plugin>
            <groupId>com.github.wvengen</groupId>
            <artifactId>proguard-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>process-classes-with-proguard</id>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>proguard</goal>
                    </goals>
                    <configuration>
                        <maxMemory>256m</maxMemory>
                        <injar>classes</injar>
                        <libs>
                            <lib>${rt.jar.path}</lib>
                            <lib>${jsse.jar.path}</lib>
                        </libs>
                        <obfuscate>true</obfuscate>
                        <attach>true</attach>
                        <addMavenDescriptor>false</addMavenDescriptor>
                        <proguardInclude>${project.basedir}/proguard.conf</proguardInclude>
                    </configuration>
                </execution>
            </executions>
        </plugin>

UPDATE: For my Android projects I'm not using a dedicated Proguard plugin like proguard-maven-plugin since the android-maven-plugin handles the ProGuard obfuscation itself, and is integrated better into the build process for Android.

There is a fork of original proguard-maven-plugin. It's git-hubed. Please see how you do it.

Here comes the latest example how we do it. No more profiles required.

I found a solution here: https://groups.google.com/forum/?fromgroups#!topic/pyx4me-users/NUZi1oySvQE. Basically I had to download and install ProGuard to my local repo.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!