混淆器:无法读取 [C:\Program Files\AdoptOpenJDK\jdk-11.0.6.10-hotspot\lib\rt.jar]

proguard: Can't read [C:\Program Files\AdoptOpenJDK\jdk-11.0.6.10-hotspot\lib\rt.jar]

我正在构建桌面应用程序。我正在使用具有以下配置的 ProGuard:

@proguard_jmods.cfg
#-dontshrink
-dontoptimize
#-dontobfuscate


-repackageclasses ''
-renamesourcefileattribute SourceFile
-keepattributes *Annotation*,Signature,Annotation,InnerClasses,EnclosingMethod,SourceFile,LineNumberTable
-adaptresourcefilenames
-dontnote
-dontwarn com.ctc.wstx.**,com.github.**,com.jolbox.bonecp.**,com.mchange.v2.**,com.sun.istack.**,com.sun.tools.**,com.healthmarketscience.**,com.healthmarketscience.**,org.codehaus.**,org.iq80.snappy.**,com.sun.xml.**,com.thoughtworks.xstream.**,de.l3s.boilerpipe.**,javax.activation.**,javax.transaction.**,net.sf.ehcache.**,opennlp.tools.util.**,org.apache.cxf.**,org.apache.log4j.**,org.apache.poi.**,org.apache.sis.**,org.apache.**,org.dom4j.**,org.codehaus.plexus.**,javax.enterprise.**,org.glassfish.**,org.jdesktop.**,org.quartz.**,com.sun.org.**,javax.imageio.metadata.**,javax.xml.**,javax.jws.**,org.w3c.dom.**,org.xml.sax.**,au.com.bytecode.**,com.fasterxml.jackson.**,com.google.common.**,com.google.gson.**,com.googlecode.mp4parser.**,com.itextpdf.**,com.mchange.v1.**,com.microsoft.schemas.**,com.strobel.assembler.**,com.strobel.compilerservices.**,examples.RCallerScriptEngineExample1.**,examples.RCallerScriptEngineExample2.**,examples.RCallerScriptEngineExample2.**,examples.RCallerScriptEngineExample3.**,javassist.util.HotSwapAgent.**,javassist.util.HotSwapper.**,javax.rmi.CORBA.**,javax.rmi.CORBA.**,javax.rmi.PortableRemoteObject.**,org.bouncycastle.**,org.cyberneko.**,org.eclipse.jetty.**,org.etsi.uri.**,org.jboss.com.**,org.jdom2.**,org.jfree.**,org.joda.time.**,org.terracotta.quartz.**,ucar.nc2.grib.**,javax.imageio.metadata.**,com.jmatio.io.**,javax.script.**,com.sun.**,java.rmi.**,opennlp.tools.sentiment.**,java.lang.**,java.util.**,sun.misc.Unsafe.**,sun.**,org.w3.**,net.sf.ehcache.distribution.**,org.apache.http.**,org.apache.any23.**,com.graphbuilder.curve.**,com.strobel.decompiler.**,com.uwyn.jhighlight.**,rg.codehaus.stax2.**,org.openxmlformats.schemas.**,org.springframework.**,org.slf4j.**,com.mysql.**,org.pushingpixels.**,org.hibernate.**,org.jboss.**,net.bytebuddy.**,javax.persistence.**,org.eclipse.**,java.awt.datatransfer.**,java.sql.**,org.objectweb.**,org.apache.any23.**
-ignorewarnings
-verbose
-printseeds seed

# Keep - Applications. Keep all application classes, along with their 'main' methods.
-keepclasseswithmembers public class * {
    public static void main(java.lang.String[]);
}

-keep interface *
-keepnames class ** implements com.xxx.xx.utils.ISerialisable
-keepclassmembers class ** implements com.xxx.xx.utils.ISerialisable {
  <fields>;
  }

-keep,allowshrinking class ** extends com.xxx.xx.utils.ISerialisable

# Keep - Applications. Keep all application classes, along with their 'main' methods.
-keepclasseswithmembers public class * {
    public static void main(java.lang.String[]);
}

# Also keep - Enumerations. Keep the special static methods that are required in
# enumeration classes.
-keepclassmembers enum  * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

# Also keep - Database drivers. Keep all implementations of java.sql.Driver.
-keep class * extends java.sql.Driver

# Keep - Native method names. Keep all native class/method names.
-keepclasseswithmembers,includedescriptorclasses,allowshrinking class * {
    native <methods>;
}

其中 proguard_jmods.cfg 包含以下内容:

-libraryjars 'C:\Program Files\AdoptOpenJDK\jdk-11.0.6.10-hotspot\jmods\java.base.jmod'
-libraryjars 'C:\Program Files\AdoptOpenJDK\jdk-11.0.6.10-hotspot\jmods\java.desktop.jmod'
-libraryjars 'C:\Program Files\AdoptOpenJDK\jdk-11.0.6.10-hotspot\jmods\java.xml.jmod'

当 运行 As>Maven Install 时,抛出以下异常:

[proguard] java.io.IOException: Can't read [C:\Program Files\AdoptOpenJDK\jdk-11.0.6.10-hotspot\lib\rt.jar] (No such file or directory: C:\Program Files\AdoptOpenJDK\jdk-11.0.6.10-hotspot\lib\rt.jar)

我检查了那个文件的路径,但我没有。知道如何解决这个问题吗? 谢谢!

编辑: Pom 文件:

<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>xxx</groupId>
    <artifactId>xxxx</artifactId>
    <version>0.0.2</version>
    <name>xxxx</name>
    
    <properties>
        <jre.version>jre11</jre.version>
        <java.version>11</java.version>
        <jdk.version>11</jdk.version>
        <jodatime.version>2.5</jodatime.version>
        <junit.version>4.13</junit.version>
        <maven.test.skip>true</maven.test.skip>
        <proguard.skip>false</proguard.skip>
    </properties>

    <repositories>
        <repository>
            <releases>
                <updatePolicy>daily</updatePolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>central</id>
            <name>Maven Repository Switchboard</name>
            <url>https://repo1.maven.org/maven2</url>
        </repository>
        <repository>
            <id>bedatadriven</id>
            <name>bedatadriven public repo</name>
            <url>https://nexus.bedatadriven.com/content/groups/public/</url>
        </repository>
        <repository>
            <id>oss.sonatype.org-snapshot</id>
            <url>http://oss.sonatype.org/content/repositories/snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <releases>
                <updatePolicy>never</updatePolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>central</id>
            <name>Maven Repository Switchboard</name>
            <url>https://repo1.maven.org/maven2</url>
        </pluginRepository>
    </pluginRepositories>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.xxxx</groupId>
                <artifactId>x</artifactId>
                <version>0.0.2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-sql_2.12</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>xml-apis</groupId>
                    <artifactId>xml-apis</artifactId>
                </exclusion>

            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-mllib_2.12</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>ooxml-schemas</artifactId>
        </dependency>
        <dependency>
            <groupId>net.sf.opencsv</groupId>
            <artifactId>opencsv</artifactId>
        </dependency>

        <dependency>
            <groupId>com.crealytics</groupId>
            <artifactId>spark-excel_2.12</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>xml-apis</groupId>
                    <artifactId>xml-apis</artifactId>
                </exclusion>

            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
        </dependency>

        <dependency>
            <groupId>org.codehaus.guessencoding</groupId>
            <artifactId>guessencoding</artifactId>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.jdesktop.swingx</groupId>
            <artifactId>jxmapviewer2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.any23</groupId>
            <artifactId>apache-any23-encoding</artifactId>
        </dependency>

        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j</artifactId>
            <type>pom</type>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>2.10</version>
                <configuration>
                    <generateBackupPoms>false</generateBackupPoms>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>false</downloadJavadocs>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M4</version>
                <configuration>
                    <argLine>
                        --illegal-access=permit
                    </argLine>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>3.0.0-M4</version>
                <configuration>
                    <argLine>
                        --illegal-access=permit
                    </argLine>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <!-- Run shade goal on package phase -->
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <id>x</id>
                        <configuration>
                            <transformers>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.xxxx.x.exe.x</mainClass>
                                </transformer>
                            </transformers>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>module-info.java</exclude>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <finalName>${project.artifactId}-${project.version}</finalName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.github.wvengen</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <version>2.2.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>proguard</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <proguardVersion>6.2.2</proguardVersion>
                    <obfuscate>true</obfuscate>
                    <injar>${project.artifactId}-0.0.2.jar</injar>
                    <outjar>${project.artifactId}-0.0.2.jar</outjar>
                    <outputDirectory>${project.build.directory}</outputDirectory>
                    <proguardInclude>${basedir}/proguard/proguard.cfg</proguardInclude>
                    <libs>
                    <lib>${java.home}/lib/rt.jar</lib>
                    <lib>${java.home}/lib/jsse.jar</lib>
                    </libs>
                    <skip>${proguard.skip}</skip>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>net.sf.proguard</groupId>
                        <artifactId>proguard-base</artifactId>
                        <version>6.2.2</version>
                        <scope>runtime</scope>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId> org.apache.maven.plugins </groupId>
                                        <artifactId> maven-compiler-plugin </artifactId>
                                        <versionRange> [2.5.1,) </versionRange>
                                        <goals>
                                            <goal>testCompile</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <resources>
            <resource>
                <targetPath></targetPath>
                <filtering>false</filtering>
                <directory>${basedir}/src/main/resources</directory>
            </resource>
            <resource>
                <directory>${basedir}/src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/config.properties</include>
                </includes>
            </resource>

            <resource>
                <targetPath></targetPath>
                <filtering>false</filtering>
                <directory>${basedir}/src/main/resources/files</directory>
            </resource>

            <resource>
                <filtering>false</filtering><!-- if it is neccessary -->
                <directory>${project.basedir}/${jre.version}</directory><!-- from -->
                <targetPath>${project.build.directory}/${jre.version}</targetPath><!-- 
                    to -->
                <includes><!-- what -->
                    <include>**</include>
                </includes>
            </resource>
        </resources>
        <testResources>
        </testResources>
    </build>
</project>

您的混淆器配置中有行 <lib>${java.home}/lib/rt.jar</lib>。这在 JDK11 中不再有效,因为它在 Java.

的那个版本中被删除了

对于较新的 JDK,请参阅:Proguard: Can't read C:\Program Files\Java\jdk-15.0.1\lib\rt.jar (No such file or directory)