我该如何在JDK 10 / JDK 11上运行Proguard并设置Maven插件?
答案 0 :(得分:1)
首先,Proguard 6.0.3尚未在Java 11上运行 (#188支持Java 11,请参见https://sourceforge.net/p/proguard/feature-requests/188/)。
您的源代码可以使用JDK 11进行编译。对于proguard插件,我们必须使用JDK 10。
在maven-compiler-plugin中,将版本设置为JDK 10:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>10</source>
<target>10</target>
<compilerArgs>
<arg>--add-modules=[required modules]</arg>
</compilerArgs>
</configuration>
</plugin>
JDK 10的属性(可以使用OpenJDK):
<properties>
<java.home.openjdk10>[pathtoJDK20]\jdk-10.0.2</java.home.openjdk10>
</properties>
proguard-maven-plugin:
<plugin>
<groupId>com.github.dingxin</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>1.0.3</version>
<executions>
<execution>
<id>process-classes-with-proguard</id>
<phase>test</phase>
<goals>
<goal>proguard</goal>
</goals>
<configuration>
<options>
<option>[proguarg options]</option>
</options>
<libs>
<lib>${java.home.openjdk10}/lib/jrt-fs.jar</lib>
<lib>${java.home.openjdk10}/jmods/java.base.jmod(!.jar;!module-info.class)</lib>
<lib>${java.home.openjdk10}/jmods/java.compiler.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.corba.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.datatransfer.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.desktop.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.instrument.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.logging.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.management.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.management.rmi.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.naming.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.prefs.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.rmi.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.scripting.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.se.ee.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.se.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.security.jgss.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.security.sasl.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.smartcardio.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.sql.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.sql.rowset.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.transaction.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.xml.bind.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.xml.crypto.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.xml.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.xml.ws.annotation.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.xml.ws.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.accessibility.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.aot.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.attach.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.charsets.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.compiler.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.crypto.cryptoki.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.crypto.ec.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.crypto.mscapi.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.dynalink.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.editpad.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.hotspot.agent.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.httpserver.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.incubator.httpclient.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.internal.ed.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.internal.jvmstat.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.internal.le.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.internal.opt.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.internal.vm.ci.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.internal.vm.compiler.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.internal.vm.compiler.management.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jartool.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.javadoc.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jcmd.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jconsole.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jdeps.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jdi.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jdwp.agent.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jlink.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jshell.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jsobject.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jstatd.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.localedata.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.management.agent.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.management.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.naming.dns.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.naming.rmi.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.net.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.pack.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.rmic.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.scripting.nashorn.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.scripting.nashorn.shell.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.sctp.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.security.auth.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.security.jgss.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.unsupported.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.xml.bind.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.xml.dom.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.xml.ws.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.zipfs.jmod</lib>
</libs>
</configuration>
</execution>
</executions>
</plugin>