我正在尝试将proguard-maven-plugin
与proguardVersion 6.0.3
一起使用。这是pom.xml中的插件声明:
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<proguardVersion>6.0.3</proguardVersion>
<injar>${project.build.finalName}.jar</injar>
<outjar>${project.build.finalName}.jar</outjar>
<obfuscate>true</obfuscate>
<options>
<option>-dontshrink</option>
<option>-dontoptimize</option>
<!-- This option will replace all strings in reflections method invocations with new class names. For example, invokes Class.forName('className') -->
<option>-adaptclassstrings</option>
<!-- This option will save all original annotations and etc. Otherwise all we be removed from files. -->
<option>-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
</option>
<!-- This option will save all original names in interfaces (without obfuscate). -->
<option>-keepnames interface **</option>
<!-- This option will save all original methods parameters in files defined in -keep sections, otherwise all parameter names will be obfuscate. -->
<option>-keepparameternames</option>
<!-- This option will save all original class files (without obfuscate) but obfuscate all in domain package. -->
<option>-keep class !com.slm.proguard.example.spring.boot.domain.** { *; }</option>
<!-- This option will save all original class files (without obfuscate) in service package -->
<!--<option>-keep class com.slm.proguard.example.spring.boot.service { *; }</option> -->
<!-- This option will save all original interfaces files (without obfuscate) in all packages. -->
<option>-keep interface * extends * { *; }</option>
<!-- This option will save all original defined annotations in all class in all packages. -->
<option>-keepclassmembers class * {
@org.springframework.beans.factory.annotation.Autowired *;
@org.springframework.beans.factory.annotation.Value *;
}
</option>
</options>
<libs>
<!-- Include main JAVA library required. -->
<lib>${java.home}/lib/rt.jar</lib>
<!-- Include crypto JAVA library if necessary. -->
<lib>${java.home}/lib/jce.jar</lib>
</libs>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>6.0.3</version>
</dependency>
</dependencies>
</plugin>
现在在Maven构建过程中,它失败并显示以下错误:
[proguard] Note: duplicate definition of library class [javax.el.ArrayELResolver]
[proguard] Note: duplicate definition of library class [javax.el.BeanELResolver$1]
[proguard] Note: duplicate definition of library class [javax.el.BeanELResolver$BeanProperties]
[proguard] Note: duplicate definition of library class [javax.el.BeanELResolver$BeanProperty]
[proguard] Note: duplicate definition of library class [javax.el.BeanELResolver]
[proguard] Note: duplicate definition of library class [javax.el.BeanNameELResolver]
[proguard] Note: duplicate definition of library class [javax.el.BeanNameResolver]
[proguard] Note: duplicate definition of library class [javax.el.CompositeELResolver]
[proguard] Note: duplicate definition of library class [javax.el.ELClass]
[proguard] Note: duplicate definition of library class [javax.el.ELContext]
[proguard] Note: duplicate definition of library class [javax.el.ELContextEvent]
[proguard] Note: duplicate definition of library class [javax.el.ELContextListener]
[proguard] Note: duplicate definition of library class [javax.el.ELException]
[proguard] Note: duplicate definition of library class [javax.el.ELManager]
[proguard] Note: duplicate definition of library class [javax.el.ELProcessor]
[proguard] Note: duplicate definition of library class [javax.el.ELResolver]
[proguard] Note: duplicate definition of library class [javax.el.EvaluationListener]
[proguard] Note: duplicate definition of library class [javax.el.Expression]
[proguard] Note: duplicate definition of library class [javax.el.ExpressionFactory]
[proguard] Note: duplicate definition of library class [javax.el.FunctionMapper]
[proguard] Note: duplicate definition of library class [javax.el.ImportHandler]
[proguard] Note: duplicate definition of library class [javax.el.LambdaExpression]
[proguard] Note: duplicate definition of library class [javax.el.ListELResolver]
[proguard] Note: duplicate definition of library class [javax.el.MapELResolver]
[proguard] Note: duplicate definition of library class [javax.el.MethodExpression]
[proguard] Note: duplicate definition of library class [javax.el.MethodInfo]
[proguard] Note: duplicate definition of library class [javax.el.MethodNotFoundException]
[proguard] Note: duplicate definition of library class [javax.el.PropertyNotFoundException]
[proguard] Note: duplicate definition of library class [javax.el.PropertyNotWritableException]
[proguard] Note: duplicate definition of library class [javax.el.ResourceBundleELResolver]
[proguard] Note: duplicate definition of library class [javax.el.StandardELContext$1]
[proguard] Note: duplicate definition of library class [javax.el.StandardELContext]
[proguard] Note: duplicate definition of library class [javax.el.StaticFieldELResolver]
[proguard] Note: duplicate definition of library class [javax.el.TypeConverter]
[proguard] Note: duplicate definition of library class [javax.el.ValueExpression]
[proguard] Note: duplicate definition of library class [javax.el.ValueReference]
[proguard] Note: duplicate definition of library class [javax.el.VariableMapper]
[proguard] Reading library jar [C:\Users\Alexander\.m2\repository\javax\interceptor\javax.interceptor-api\1.2\javax.interceptor-api-1.2.jar]
[proguard] Reading library jar [C:\Users\Alexander\.m2\repository\javax\inject\javax.inject\1\javax.inject-1.jar]
[proguard] Reading library jar [C:\Users\Alexander\.m2\repository\javax\transaction\jta\1.1\jta-1.1.jar]
[proguard] Reading library jar [C:\Users\Alexander\.m2\repository\org\apache\commons\commons-lang3\3.7\commons-lang3-3.7.jar]
[proguard] Reading library jar [C:\Users\Alexander\.m2\repository\commons-validator\commons-validator\1.6\commons-validator-1.6.jar]
[proguard] Reading library jar [C:\Users\Alexander\.m2\repository\commons-beanutils\commons-beanutils\1.9.2\commons-beanutils-1.9.2.jar]
[proguard] Reading library jar [C:\Users\Alexander\.m2\repository\commons-digester\commons-digester\1.8.1\commons-digester-1.8.1.jar]
[proguard] Reading library jar [C:\Users\Alexander\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar]
[proguard] Note: duplicate definition of library class [org.apache.commons.logging.impl.SimpleLog]
[proguard] Note: duplicate definition of library class [org.apache.commons.logging.impl.NoOpLog]
[proguard] Note: duplicate definition of library class [org.apache.commons.logging.LogFactory]
[proguard] Note: duplicate definition of library class [org.apache.commons.logging.LogFactory$1]
[proguard] Note: duplicate definition of library class [org.apache.commons.logging.LogFactory$2]
[proguard] Note: duplicate definition of library class [org.apache.commons.logging.Log]
[proguard] Reading library jar [C:\Users\Alexander\.m2\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar]
[proguard] Reading library jar [C:\Users\Alexander\.m2\repository\commons-io\commons-io\2.6\commons-io-2.6.jar]
[proguard] Reading library jar [C:\Users\Alexander\.m2\repository\org\apache\commons\commons-compress\1.16.1\commons-compress-1.16.1.jar]
[proguard] Reading library jar [C:\Users\Alexander\.m2\repository\org\objenesis\objenesis\2.6\objenesis-2.6.jar]
[proguard] Reading library jar [C:\Users\Alexander\.m2\repository\org\apache\commons\commons-text\1.3\commons-text-1.3.jar]
[proguard] Reading library jar [C:\Java\jdk1.8.0_171\jre\lib\rt.jar]
[proguard] Note: duplicate definition of library class [javax.annotation.Generated]
[proguard] Note: duplicate definition of library class [javax.annotation.PostConstruct]
[proguard] Note: duplicate definition of library class [javax.annotation.PreDestroy]
[proguard] Note: duplicate definition of library class [javax.annotation.Resource$AuthenticationType]
[proguard] Note: duplicate definition of library class [javax.annotation.Resource]
[proguard] Note: duplicate definition of library class [javax.annotation.Resources]
[proguard] Note: duplicate definition of library class [javax.transaction.InvalidTransactionException]
[proguard] Note: duplicate definition of library class [javax.transaction.TransactionRequiredException]
[proguard] Note: duplicate definition of library class [javax.transaction.TransactionRolledbackException]
[proguard] Note: duplicate definition of library class [javax.transaction.xa.XAException]
[proguard] Note: duplicate definition of library class [javax.transaction.xa.XAResource]
[proguard] Note: duplicate definition of library class [javax.transaction.xa.Xid]
[proguard] Reading library jar [C:\Java\jdk1.8.0_171\jre\lib\jce.jar]
[proguard] Note: there were 57 duplicate class definitions.
[proguard] (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
[proguard] Warning: there were 2 classes in incorrectly named files.
[proguard] You should make sure all file names correspond to their class names.
[proguard] The directory hierarchies must correspond to the package hierarchies.
[proguard] (http://proguard.sourceforge.net/manual/troubleshooting.html#unexpectedclass)
[proguard] If you don't mind the mentioned classes not being written out,
[proguard] you could try your luck using the '-ignorewarnings' option.
[proguard] Error: Please correct the above warnings first.
我在做什么错以及如何解决?
答案 0 :(得分:0)
输出日志在一开始就被剪切掉了,所以我看不到哪个软件包引起了这两个警告, 但是如果您使用的是Spring,则可能是log4j引起了问题。
您可以通过添加
进行修复<option>-dontwarn **log4j**,**module-info</option>