【问题标题】:Maven Proguard plugin - "proguard.Proguard not found on classpath" errorMaven Proguard 插件 - “proguard.Proguard not found on classpath”错误
【发布时间】:2021-10-19 14:17:33
【问题描述】:

我使用的是 Java 8,但我必须使用新版本的 Proguard 和 Proguard Maven 插件,因为它覆盖了来自更高版本的一些 jar 依赖项(否则我会收到“不支持的主要-次要版本”问题) .

当执行“mvn clean install”时,该步骤被执行,但我得到一个“proguard jar not found in pluginArtifacts error”。请参阅下面的日志。

我在 Proguard Maven 插件code 中看到,现在您需要(从 7.0.0 开始)com.guardsquare 中的 proguard-base 和 proguard-core,而不是 net.sf.proguard 中过时的先前版本 - 这个没有为以后的罐子做好准备。

显然在我指定的地方找不到 proguard jar - 我应该如何包含此依赖项?

我在我的 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>

使用 -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]

jar-with-dependencies 是使用 Maven Assembly 插件生成的。 我使用的是 Java 1.8。

【问题讨论】:

    标签: java maven proguard obfuscation proguard-maven-plugin


    【解决方案1】:

    我实际上使用的是 proguard.Proguard 而不是 proguard.ProGuard。 Typo 花了我一天的时间。

    但是,有一些额外的技巧相关联,以防它帮助任何人:proguard-maven-plugin 不会让我定义新版本的 proguard 依赖项,除了默认的依赖项。例如。 2.4.0 只允许我使用默认的7.1.0-beta3。它无法识别我将在插件内的dependencies 部分中设置的库(例如,7.1.1)。

    【讨论】:

    • 使用 proguard-maven-plugin:2.5.3 我解决了使用 7​​.2.0-beta5 而不是属性
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-25
    • 2013-02-20
    相关资源
    最近更新 更多