如何使ProGuard Maven插件使用最新的ProGuard版本?

时间:2015-02-07 17:30:38

标签: java maven maven-3 proguard obfuscation

我有一个pom.xml文件,如下所示。当我运行mvn clean install时,我收到错误

[proguard] Error: Can't read [C:\Program Files\Java\jdk1.8.0_20\jre\lib\rt.jar] 
(Can't process class [com/oracle/net/Sdp$1.class] (Unsupported class version number 
[52.0] (maximum 51.0, Java 1.7)))

我尝试升级ProGuard版本并将其设置为5.2文件中的pom.xml

但是当我运行mvn clean install时,我会在控制台中收到以下消息:

[INFO] proguard jar: C:\Users\DP118M\.m2\repository\net\sf\proguard\proguard-base\4.11\proguard-base-4.11.jar
 [proguard] ProGuard, version 4.11

如何使Maven ProGuard插件使用ProGuard 5.2版而不是4.11?

这里是完整的pom.xml:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>ru.mycompany</groupId>
    <artifactId>myproduct</artifactId>
    <version>1.0.10-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <powermock.version>1.5.1</powermock.version>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.wvengen</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <version>2.0.7</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals><goal>proguard</goal></goals>
                    </execution>
                </executions>
                <configuration>
                    <proguardVersion>5.2</proguardVersion>
                    <options>
                        <option>-allowaccessmodification</option>
                        <option>-dontshrink</option>
                        <option>-dontoptimize</option>
                        <option>-dontnote</option>
                        <option>-keepattributes Signature</option>
                        <option>-keep class ru.mycompany.prd.myproduct.myproductApp { *; }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.api.gui.IGlassPaneObjectsDisplay { *; }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.api.misc.IPersistenceForSimulationAuthors { *; }</option>
                        <option>-keep interface com.roots.map.overlay.ILatLongToScreenCoordinatesConverter { *; }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.api.gui.IMenuBarFactory { *; }</option>
                        <option>-keepclassmembers enum ru.mycompany.prd.myproduct.api.osm.BuildingType {
                        public static **[] values();
                        public static ** valueOf(java.lang.String);
                        }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.api.gui.IControlPanelBuilder { *; }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.api.demography.IPerson { *; }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.api.osm.IBuilding { *; }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.api.osm.IWay { *; }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.api.misc.ISimulationInfo { *; }</option>
                        <option>-keep class ru.mycompany.prd.myproduct.ApplicationStateForSimulationAuthors { *; }</option>
                        <option>-keep enum ru.mycompany.prd.myproduct.impl.gui.ApplicationStateSingleton { *; }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.api.gui.IApplicationState { *; }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.api.gui.IEventBus { *; }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.api.gui.IMouseEventListener { *; }</option>
                        <option>-keep class ru.mycompany.prd.myproduct.impl.osm.Building { *; }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.api.gui.IPolygon { *; }</option>
                        <option>-keep interface
                            ru.mycompany.prd.myproduct.api.gui.IGlassPaneRepainter { *; }</option>
                        <option>-keep class ru.mycompany.prd.myproduct.impl.gui.GuiUtils { *; }</option>
                        <option>-keep class ru.mycompany.prd.myproduct.impl.osm.Road { *; }</option>
                        <option>-keep class ru.mycompany.prd.myproduct.impl.osm.PolyLine { *; }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.api.osm.IRoad { *;
                            }</option>
                        <option>-keep interface
                            ru.mycompany.prd.myproduct.api.gui.IStandardVisualElementPainter { *; }</option>
                        <option>-keep class ru.mycompany.prd.myproduct.actions.ApartmentBuildingAction  { *; }</option>
                        <option>-keep class ru.mycompany.prd.myproduct.actions.RoadAction  { *; }</option>
                        <option>-keep class ru.mycompany.prd.myproduct.actionsgui.ActionsDialog  { *; }</option>
                        <option>-keep class ru.mycompany.prd.myproduct.actionsgui.ActionsTableModel  { *; }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.models.IPeopleBehaviourModel  { *; }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.actions.IAction  { *; }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.actionsgui.IActionCollection  { *; }</option>
                        <option>-keep interface
                            ru.mycompany.prd.myproduct.impl.controller.IPersistenceInitializedListener { *; }</option>
                        <option>-keep class ru.mycompany.prd.myproduct.kpi.AbstractSensor  { *; }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.kpi.ISensor  { *; }</option>
                        <option>-keep interface ru.mycompany.prd.myproduct.kpi.ISensorDataDisplay  { *; }</option>
                        <option>-keep enum ru.mycompany.prd.myproduct.api.demography.Gender { *; }</option>
                    </options>
                    <libs>
                        <lib>${java.home}/lib/rt.jar</lib>
                    </libs>
                    <dependencies>
                        <dependency>
                            <groupId>net.sf.proguard</groupId>
                            <artifactId>proguard-base</artifactId>
                            <version>5.2</version>
                            <scope>runtime</scope>
                        </dependency>
                    </dependencies>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.easytesting</groupId>
            <artifactId>fest-util</artifactId>
            <version>1.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-support</artifactId>
            <version>1.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-reflect</artifactId>
            <version>1.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-core</artifactId>
            <version>1.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.easytesting</groupId>
            <artifactId>fest-assert-core</artifactId>
            <version>2.0M8</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>15.0</version>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.9.5</version>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.3.173</version>
        </dependency>
        <dependency>
            <groupId>ru.mycompany</groupId>
            <artifactId>commons</artifactId>
            <version>2.9</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4</artifactId>
            <version>${powermock.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito</artifactId>
            <version>${powermock.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymock</artifactId>
            <version>3.2</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-easymock</artifactId>
            <version>${powermock.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>0.9.26</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>0.9.26</version>
        </dependency>
        <dependency>
            <groupId>net.sf.opencsv</groupId>
            <artifactId>opencsv</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>org.jgrapht</groupId>
            <artifactId>jgrapht-jdk1.5</artifactId>
            <version>0.7.3</version>
        </dependency>
        <dependency>
            <groupId>jgraph</groupId>
            <artifactId>jgraph</artifactId>
            <version>5.13.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.soundlibs</groupId>
            <artifactId>jlayer</artifactId>
            <version>1.0.1-1</version>
        </dependency>
        <dependency>
            <groupId>com.javadocmd</groupId>
            <artifactId>simplelatlng</artifactId>
            <version>1.3.0</version>
        </dependency>
        <!-- Overpass stuff (start) -->
        <dependency>
            <groupId>se.kodapan.osm.common</groupId>
            <artifactId>core</artifactId>
            <version>0.0.2-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>se.kodapan.osm.common</groupId>
            <artifactId>java</artifactId>
            <version>0.0.2-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.1.2</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.3</version>
        </dependency>
        <!-- Overpass stuff (end) -->
        <dependency>
            <groupId>org.javatuples</groupId>
            <artifactId>javatuples</artifactId>
            <version>1.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.vividsolutions</groupId>
            <artifactId>jts</artifactId>
            <version>1.12</version>
        </dependency>
    </dependencies>
</project>

1 个答案:

答案 0 :(得分:3)

我通过将proguard-maven-plugin的版本从2.0.7更改为2.0.8来解决了问题。