Proguard plugin is giving error: Failed to execute goal: proguard (default) on project X: Obfuscation failed (result=1)

huangapple go评论84阅读模式
英文:

Proguard plugin is giving error: Failed to execute goal: proguard (default) on project X: Obfuscation failed (result=1)

问题

我正在处理一个开源的Java Maven项目,该项目使用 proguard-maven-plugin 对应用程序代码进行混淆。在我添加了两个新的Maven依赖项之后出现了问题:

<dependency>
	<groupId>com.formdev</groupId>
	<artifactId>flatlaf</artifactId>
	<version>0.43</version>
</dependency>
<dependency>
	<groupId>com.formdev</groupId>
	<artifactId>flatlaf-intellij-themes</artifactId>
	<version>0.43</version>
</dependency>

在此之后,当我运行 mvn clean install 命令时,出现以下错误堆栈:

[ERROR] Failed to execute goal com.github.wvengen:proguard-maven-plugin:2.0.14:proguard (default) on project X: Obfuscation failed (result=1) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.wvengen:proguard-maven-plugin:2.0.14:proguard (default) on project X: Obfuscation failed (result=1)
    ...
Caused by: org.apache.maven.plugin.MojoExecutionException: Obfuscation failed (result=1)
    ...
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

我对 Proguard 不是很了解,我已经查阅了各种帖子,试图找到错误的原因或可能的解决方案,但都没有成功。如果我移除这两个依赖项,它可以正常工作(没有任何错误)。

这是我 pom.xml 文件中的 proguard-maven-plugin 配置:

<plugin>
	<groupId>com.github.wvengen</groupId>
	<artifactId>proguard-maven-plugin</artifactId>
	<version>2.0.14</version>
	<dependencies>
		<dependency>
			<groupId>net.sf.proguard</groupId>
			<artifactId>proguard-base</artifactId>
			<version>6.0.3</version>
		</dependency>
	</dependencies>
	<executions>
		<execution>
			<phase>package</phase>
			<goals>
				<goal>proguard</goal>
			</goals>
		</execution>
	</executions>
	<configuration>
		<proguardVersion>6.0.3</proguardVersion>
		<obfuscate>true</obfuscate>
		<injar>${project.build.finalName}.jar</injar>
		<outjar>${project.build.finalName}.jar</outjar>
		<includeDependency>true</includeDependency>
		<addMavenDescriptor>true</addMavenDescriptor>
		<silent>true</silent>
		<options>
			<option>-dontshrink</option>
			<option>-optimizations no_optimizations</option>
			<option>-keep class com.X.model.** { public protected private *; }</option>
			<option>-keep class com.X.rest.service.** { public protected private *; }</option>
			<option>-keepnames class ** { public protected *; }</option>
			<option>-keepattributes *Annotation*,Signature,EnclosingMethod,InnerClasses,Exceptions,MethodParameters,SourceFile,LineNumberTable</option>
		</options>
		<libs>
			<lib>${java.home}/lib/rt.jar</lib>
			<lib>${java.home}/lib/jce.jar</lib>
		</libs>
	</configuration>
</plugin>

非常感谢您的帮助!

英文:

I am working on an open source Java Maven project which is using proguard-maven-plugin to obfuscate the application code. It is working fine until I have added 2 new maven dependencies:

&lt;dependency&gt;
	&lt;groupId&gt;com.formdev&lt;/groupId&gt;
	&lt;artifactId&gt;flatlaf&lt;/artifactId&gt;
	&lt;version&gt;0.43&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
	&lt;groupId&gt;com.formdev&lt;/groupId&gt;
	&lt;artifactId&gt;flatlaf-intellij-themes&lt;/artifactId&gt;
	&lt;version&gt;0.43&lt;/version&gt;
&lt;/dependency&gt;    

After that, I started getting the following error stack while run mvn clean install cmd:

[ERROR] Failed to execute goal com.github.wvengen:proguard-maven-plugin:2.0.14:proguard (default) on project X: Obfuscation failed (result=1) -&gt; [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.wvengen:proguard-maven-plugin:2.0.14:proguard (default) on project X: Obfuscation failed (result=1)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
Caused by: org.apache.maven.plugin.MojoExecutionException: Obfuscation failed (result=1)
    at com.github.wvengen.maven.proguard.ProGuardMojo.proguardMain (ProGuardMojo.java:814)
    at com.github.wvengen.maven.proguard.ProGuardMojo.execute (ProGuardMojo.java:617)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I don't have much idea of Proguard and I have checked various posts to find the reason for the error or possible solution, but no success at all. If I remove those two dependencies, it works as expected (without any error).

This is proguard-maven-plugin configuration in my pom.xml file:

&lt;plugin&gt;
	&lt;groupId&gt;com.github.wvengen&lt;/groupId&gt;
	&lt;artifactId&gt;proguard-maven-plugin&lt;/artifactId&gt;
	&lt;version&gt;2.0.14&lt;/version&gt;
	&lt;dependencies&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;net.sf.proguard&lt;/groupId&gt;
			&lt;artifactId&gt;proguard-base&lt;/artifactId&gt;
			&lt;version&gt;6.0.3&lt;/version&gt;
		&lt;/dependency&gt;
	&lt;/dependencies&gt;
	&lt;executions&gt;
		&lt;execution&gt;
			&lt;phase&gt;package&lt;/phase&gt;
			&lt;goals&gt;
				&lt;goal&gt;proguard&lt;/goal&gt;
			&lt;/goals&gt;
		&lt;/execution&gt;
	&lt;/executions&gt;
	&lt;configuration&gt;
		&lt;proguardVersion&gt;6.0.3&lt;/proguardVersion&gt;
		&lt;obfuscate&gt;true&lt;/obfuscate&gt;
		&lt;injar&gt;${project.build.finalName}.jar&lt;/injar&gt;
		&lt;outjar&gt;${project.build.finalName}.jar&lt;/outjar&gt;
		&lt;includeDependency&gt;true&lt;/includeDependency&gt;
		&lt;addMavenDescriptor&gt;true&lt;/addMavenDescriptor&gt;
		&lt;silent&gt;true&lt;/silent&gt;
		&lt;options&gt;
			&lt;option&gt;-dontshrink&lt;/option&gt;
			&lt;option&gt;-optimizations no_optimizations&lt;/option&gt;
			&lt;option&gt;-keep class com.X.model.** { public protected private *; }&lt;/option&gt;
			&lt;option&gt;-keep class com.X.rest.service.** { public protected private *; }&lt;/option&gt;
			&lt;option&gt;-keepnames class ** { public protected *; }&lt;/option&gt;
			&lt;option&gt;-keepattributes *Annotation*,Signature,EnclosingMethod,InnerClasses,Exceptions,MethodParameters,SourceFile,LineNumberTable&lt;/option&gt;
		&lt;/options&gt;
		&lt;libs&gt;
			&lt;lib&gt;${java.home}/lib/rt.jar&lt;/lib&gt;
			&lt;lib&gt;${java.home}/lib/jce.jar&lt;/lib&gt;
		&lt;/libs&gt;
	&lt;/configuration&gt;
&lt;/plugin&gt; 

Any help would be appreciated. Thanks in advance!

答案1

得分: 1

在更新了 proguard-maven-plugin 版本之后,我再也没有看到这个问题。我已经将插件版本更新为 2.3.1

英文:

After updating the proguard-maven-plugin version, I am not seeing the issue anymore. I have updated the plugin version to 2.3.1.

答案2

得分: 0

我在插件之前添加了 pluginManagement,然后错误消失了。

英文:

I have added pluginManagement
before plugins and the error was disappeared.

huangapple
  • 本文由 发表于 2020年10月21日 21:07:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/64464231.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定