I have a maven project with a parent module and 6 sub-modules. 3 of them are applications and the rest are the common modules that the 3 apps depend on.
The parent module only has a pom.xml without any code. I’m trying to use proguard to obfuscate all the 6 modules. The proguard maven plugin is defined in the parent pom.
The issue is when I run mvn package, I got error
[proguard] java.io.IOException: The input is empty. You have to specify one or more '-injars' options.
I think it’s because the parent module doesn’t have any code (thus no class files or jars) so it cannot find a input jar. My proguard config is as below:
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.6.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<injar>${project.build.finalName}.jar</injar>
<outjar>${project.build.finalName}-small.jar</outjar>
<obfuscate>true</obfuscate>
<proguardInclude>${project.basedir}/../proguard.cfg</proguardInclude>
<libs>
<lib>${java.home}/jmods/java.base.jmod</lib>
<lib>${java.home}/jmods/java.management.jmod</lib>
<lib>${java.home}/jmods/jdk.management.jmod</lib>
<lib>${java.home}/jmods/java.sql.jmod</lib>
<lib>${java.home}/jmods/java.xml.jmod</lib>
</libs>
<outputDirectory>${project.basedir}/target</outputDirectory>
</configuration>
</plugin>
I also tried to run it in a child module and it succeeded. So I guess it just couldn’t find a ${project.build.finalName}.jar
in the parent module.
I wonder if I can fix it by:
- Tweak some configs in proguard OR
- use another obfuscation plugin if proguard doesn’t support my case OR
- Do not run the plugin in parent module, only run it in the child modules. (not sure if possible?)