ProGuard + Maven with Java 7

后端 未结 3 1622
盖世英雄少女心
盖世英雄少女心 2021-02-01 20:57

I\'m trying to make ProGuard part of our Maven build process. The problem is that the official Maven plugin is using ProGuard 4.3, which doesn\'t support Java 7. Is there any ea

相关标签:
3条回答
  • 2021-02-01 21:09

    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.

    0 讨论(0)
  • 2021-02-01 21:14

    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.

    0 讨论(0)
  • 2021-02-01 21:18

    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.

    0 讨论(0)
提交回复
热议问题