我想用 ProGuard 混淆我的库,并将以下代码添加到pom.xml
:
<build>
<plugins>
...
<plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<options>
<option>-allowaccessmodification</option>
<option>-keep class mypackage.AbstractSimulationFacadeTest</option>
</options>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
</libs>
</configuration>
</plugin>
</plugins>
</build>
mypackage.AbstractSimulationFacadeTest
是在 中定义的类src/test/java
。它用于单元测试。
当我运行时mvn install
,ProGuard 抱怨它找不到类mypackage.AbstractSimulationFacadeTest
:
[proguard] Note: the configuration refers to the unknown class 'mypackage.AbstractSimulationFacadeTest'
[proguard] Note: there were 1 references to unknown classes.
[proguard] You should check your configuration for typos.
[proguard] Error: The output jar is empty. Did you specify the proper '-keep' options?
当我删除线
<option>-keep class mypackage.AbstractSimulationFacadeTest</option>
并运行mvn install
,我得到一个ClassNotFoundError
for mypackage.AbstractSimulationFacadeTest
。
我应该如何更改我的pom.xml
文件以使mvn install
运行没有错误?