问题场景
在使用Maven + Proguard打包项目进行混淆时,提示以下错误:
[proguard] ProGuard, version 4.4
[proguard] Reading input...
[proguard] java.io.IOException: The input doesn‘t contain any classes. Did you specify the proper ‘-injars‘ options?
[proguard] at proguard.InputReader.execute(InputReader.java:91)
[proguard] at proguard.ProGuard.readInput(ProGuard.java:195)
[proguard] at proguard.ProGuard.execute(ProGuard.java:78)
[proguard] at proguard.ProGuard.main(ProGuard.java:499)
问题分析
缺少injars配置项!
-injars {class_path} 指定要处理的应用程序jar,war,ear和目录
解决方案
添加injars配置项,由于是Web项目,所以这里指定的是war
<injar>${project.build.finalName}.war</injar>
完整示例:
<plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<obfuscate>true</obfuscate>
<proguardInclude>${basedir}/proguard.conf</proguardInclude>
<!-- 添加依赖,这里你可以按你的需要修改 -->
<libs>
<lib>${java.home}/lib/rt.jar</lib>
<lib>lib/jsp-api.jar</lib>
<lib>lib/servlet-api.jar</lib>
</libs>
<addMavenDescriptor>false</addMavenDescriptor>
<injar>${project.build.finalName}.war</injar>
<outjar>${project.build.finalName}-pg.war</outjar>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
<dependencies>
<!-- 使用4.4版本来混淆 -->
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard</artifactId>
<version>4.4</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
java.io.IOException: The input doesn't contain any classes. Did you specify the proper '-injars' opt
时间: 2024-10-12 20:32:15