Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The input is empty. You have to specify one or more '-injars' options #348

Open
takeAction opened this issue Jun 20, 2024 · 4 comments
Open

Comments

@takeAction
Copy link

takeAction commented Jun 20, 2024

spring boot 2.x, jdk 1.8, maven 3.5, proguard 7.2.2 and proguard-maven-plugin 2.6.0.
my configuration as follows:

<properties>

		<war.output.dictionary>wars/</war.output.dictionary>

</properties>
....
<build>
		...
		<plugins>
						
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>				
				<configuration>
					<outputDirectory>${war.output.dictionary}</outputDirectory>
				</configuration>
			</plugin>
			<plugin>
				<groupId>com.github.wvengen</groupId>
				<artifactId>proguard-maven-plugin</artifactId>
				<version>2.6.0</version>
				<executions>
					<execution>
						<phase>compile</phase>
						<goals>
							<goal>proguard</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<proguardVersion>7.2.2</proguardVersion>
					<obfuscate>true</obfuscate>
					<proguardInclude>E:/proguard.cfg</proguardInclude>
					<libs>
						<lib>${java.home}/lib/rt.jar</lib>
					</libs>
					<injar>classes</injar>
					<outputDirectory>proguard</outputDirectory>
				</configuration>
				<dependencies>
					<dependency>
						<groupId>com.guardsquare</groupId>
						<artifactId>proguard-base</artifactId>
						<version>7.2.2</version>
						<scope>runtime</scope>
					</dependency>
				</dependencies>
			</plugin>
		</plugins>
		
		<resources>
			<resource>
				<directory>src/main/resources</directory>  
                <filtering>true</filtering>
                <includes>
                	<include>**/*.properties</include>
                	<include>**/*.yml</include><!-- 也可以指定具体的文件 application-${env}.yml -->
                </includes>                
			</resource>
			<resource>
				<directory>src/main/resources</directory>
				<filtering>false</filtering>
				<excludes>
					<exclude>**/*.properties</exclude>
					<exclude>**/*.yml</exclude>
				</excludes>
			</resource>
		</resources>
		
	</build>

my project is packaged as war.
I want to obfuscate the war or its classes, when I execute mvn clean package in idea, the error thrown:

[proguard] ProGuard, version 7.2.2
 [proguard] Unexpected error
 [proguard] java.io.IOException: The input is empty. You have to specify one or more '-injars' options.
 [proguard] 	at proguard.ConfigurationChecker.check(ConfigurationChecker.java:62) ~[proguard-base-7.2.2.jar:7.2.2]
 [proguard] 	at proguard.ProGuard.checkConfiguration(ProGuard.java:290) ~[proguard-base-7.2.2.jar:7.2.2]
 [proguard] 	at proguard.ProGuard.execute(ProGuard.java:99) ~[proguard-base-7.2.2.jar:7.2.2]
 [proguard] 	at proguard.ProGuard.main(ProGuard.java:623) [proguard-base-7.2.2.jar:7.2.2]

what's the problem? I have set injar as classes and phase of execution as compile.

@lasselindqvist
Copy link
Collaborator

Based on your code, your injar parameter points to a directory of class files, not a JAR file. Try changing that.

@takeAction
Copy link
Author

@lasselindqvist but from plugin.xml of proguard-maven-plugin, it says the injar is about

Specifies the input jar name (or wars, ears, zips) of the application to be processed. You may specify a classes directory e. g. 'classes'. This way plugin will processed the classes instead of jar. You would need to bind the execution to phase 'compile' or 'process-classes' in this case.

does I misunderstand it?

@lasselindqvist
Copy link
Collaborator

You can see the parameter here: https://github.com/wvengen/proguard-maven-plugin/blob/master/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java#L192

See https://github.com/wvengen/proguard-maven-plugin/blob/master/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java#L434 about what happens if that directory does not exist. You have given outputDirectory parameter and maybe that is what breaks you usage of it.

Why is outputDirectory also used as input directory? I have no idea and it preceeds my time. Maybe there could be a separate inputDirectory which could default to outputDirectory if none specified (for compatibility reasons), but there is none. If you need such a solution, I could merge and release such a change.

@takeAction
Copy link
Author

I added outputDirectory of proguard-maven-plugin in my case because I want to generate the obfuscated classes in the specified folder under target directory.

After I remove this parameter, this error gone, the obfuscated classes are in classes folder and the un-obfuscated classes are in classes_proguard_base folder.
Thanks @lasselindqvist !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants