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

How to implement proguard obfuscation for a few specified jar files and output them in the original path after obfuscation? #370

Open
fendo8888 opened this issue Sep 22, 2024 · 0 comments

Comments

@fendo8888
Copy link

How can I use Proguard to confuse several specified jars and output them in the original path after obfuscation? How can I implement it as follows?

My Maven structure is as follows:

a-main package
b-tool package
c-business package

I use spring boot, and after packaging, all dependencies in spring boot will be placed in the lib directory

The desired result is to confuse a, b, and c, and then generate the corresponding packages in the original way after the obfuscation code as follows:

a-main package After obfuscation, all resources in package a are output to package a for overwriting. At this time, package a is already obfuscated

b-tool package After obfuscation, all resources in package b are output to package a for overwriting. At this time, package b is already obfuscated

c-business package After obfuscation, all resources in package c are output to package a for overwriting. At this time, package c is already obfuscated

Looking at the proguard documentation, you can use multiple injars and outjars, but an error will be reported through the proguard-maven-plugin in the proguard.cfg configuration file

-injars a.jar
-injars lib\b.jar
-injars lib\c.jar

-outjars a.jar(com/a/**)
-outjars lib\b.jar(com/b/**)
-outjars lib\c.jar(com/c/**)

I have also tried the following and it doesn't seem to work:

<plugin>
	<groupId>com.github.wvengen</groupId>
	<artifactId>proguard-maven-plugin</artifactId>
	<version>2.6.1</version>
	<executions>
		<execution>
			<id>proguard-lib-a</id>
			<goals>
				<goal>proguard</goal>
			</goals>
			<configuration>
				<obfuscate>true</obfuscate>
				<injar>a.jar</injar>
				<outjar>a.jar</outjar>
				<proguardInclude>${project.basedir}/proguard.cfg</proguardInclude>
			</configuration>
		</execution>
		<execution>
			<id>proguard-lib-b</id>
			<goals>
				<goal>proguard</goal>
			</goals>
			<configuration>
				<obfuscate>true</obfuscate>
				<injar>/lib/b-${revision}.jar</injar>
				<outjar>/lib/b-${revision}.jar</outjar>
				<proguardInclude>${project.basedir}/proguard.cfg</proguardInclude>
			</configuration>
		</execution>
		<execution>
			<id>proguard-lib-c</id>
			<goals>
				<goal>proguard</goal>
			</goals>
			<configuration>
				<obfuscate>true</obfuscate>
				<injar>/lib/c-${revision}.jar</injar>
				<outjar>/lib/c-${revision}.jar</outjar>
				<proguardInclude>${project.basedir}/proguard.cfg</proguardInclude>
			</configuration>
		</execution>
	</executions>
</plugin>

refer to:

https://stackoverflow.com/questions/49224360/proguard-multiple-injars-to-multiple-outjars-the-output-jar-must-have-a-filter
https://www.guardsquare.com/manual/configuration/examples#filtering

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

1 participant