[英]Maven Proguard plugin - "proguard.Proguard not found on classpath" error
I am trying to obfuscate a jar-with-dependencies (although the same problem affects if I set as inFile the regular single jar).我正在尝试混淆具有依赖项的 jar(尽管如果我将常规单个 jar 设置为 inFile 会影响相同的问题)。
I am using Java 8, but I have to use newer versions of Proguard and Proguard Maven Plugin, due to coverage of some jar dependencies that are from a higher version (otherwise I get an "Unsupported major-minor version" problem).我正在使用 Java 8,但我必须使用较新版本的 Proguard 和 Proguard Maven 插件,因为覆盖了来自更高版本的一些 jar 依赖项(否则我会遇到“不支持的主要-次要版本”问题)。
When executing "mvn clean install" the step is executed but I get a "proguard jar not found in pluginArtifacts error".执行“mvn clean install”时,会执行该步骤,但出现“在 pluginArtifacts 错误中找不到 proguard jar”。 See log below.
请参阅下面的日志。
I have seen in Proguard Maven Plugin code that now you need (from 7.0.0) both proguard-base and proguard-core from com.guardsquare instead of the outdated previous version in net.sf.proguard - this one is not prepared for later jars.我在 Proguard Maven 插件代码中看到,现在你需要(从 7.0.0 开始)来自 com.guardsquare 的 proguard-base 和 proguard-core,而不是 net.sf.proguard 中过时的先前版本 - 这个不是为以后准备的罐子。
Apparently the proguard jar is not found where I am specifying it - how should I include this dependency?显然,在我指定的地方找不到 proguard jar - 我应该如何包含这个依赖项?
I am using this in my pom:我在我的 pom 中使用它:
<build>
<plugins>
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals><goal>proguard</goal></goals>
<configuration>
<injar>${project.build.finalName}-jar-with-dependencies.jar</injar>
<outjar>${project.build.finalName}-small.jar</outjar>
<proguardVersion>7.1.0</proguardVersion>
<options>
<option>-allowaccessmodification</option>
<option>-dontoptimize</option>
<option>-dontshrink</option>
<option>-dontnote</option>
<option>-dontwarn</option> <!-- added option to ignore com.sun missing classes -->
<option>-keepattributes Signature</option>
</options>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
</libs>
<dependencies>
<dependency>
<groupId>com.guardsquare</groupId>
<artifactId>proguard-base</artifactId>
<version>7.1.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.guardsquare</groupId>
<artifactId>proguard-core</artifactId>
<version>7.1.0</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.4.0</version>
</plugin>
<plugins>
<pluginManagement>
</build>
Running it with -X debug flag:使用 -X 调试标志运行它:
[... proguard execution command which ends in:]
-printseeds, 'C:\workspace\xxx\target\proguard_seed.txt', -verbose, -allowaccessmodification, -dontoptimize, -dontshrink, -dontnote, -dontwarn, -keepattributes Signature]
...
[DEBUG] pluginArtifact: C:\User\myuser\.m2\repository\org\eclipse\sisu\org.eclipse.sisu.inject\0.0.0.M5\org.eclipse.sisu.inject-0.0.0.M5.jar
[DEBUG] pluginArtifact: C:\User\myuser\.m2\repository\org\codehaus\plexus\plexus-component-annotations\1.5.5\plexus-component-annotations-1.5.5.jar
[DEBUG] pluginArtifact: C:\User\myuser\.m2\repository\org\codehaus\plexus\plexus-classworlds\2.4\plexus-classworlds-2.4.jar
[INFO] proguard jar not found in pluginArtifacts
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 40.302 s
[INFO] Finished at: 2021-08-17T18:26:45
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.wvengen:proguard-maven-plugin:2.3.1:proguard (default) on project xxx: Obfuscation failed ProGuard (proguard.ProGuard) not found in classpath -> [Help 1]
The jar-with-dependencies is generated with Maven Assembly plugin. jar-with-dependencies 是用 Maven Assembly 插件生成的。 I am using Java 1.8.
我正在使用 Java 1.8。
I was actually using proguard.Proguard instead of proguard.ProGuard.我实际上使用的是 proguard.Proguard 而不是 proguard.ProGuard。 Typo took a day out of me.
打字错误让我失去了一天。
However, there is some extra trickyness associated, in case it helps anyone: proguard-maven-plugin
would not let me define newer versions of proguard dependencies except for the default one.但是,有一些额外的棘手相关联,以防它对任何人有帮助:
proguard-maven-plugin
不会让我定义除默认依赖项之外的更新版本的 proguard 依赖项。 Eg 2.4.0
would only allow me to use 7.1.0-beta3
which is the default.例如,
2.4.0
只允许我使用默认的7.1.0-beta3
。 It didn't recognize the libraries I would set in the dependencies
section inside the plugin (for example, for 7.1.1
).它无法识别我将在插件内的
dependencies
部分设置的库(例如,对于7.1.1
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.