0
votes

I'd like to run a custom action before Spring Boot Plugin builds the final WAR file. Actually I have to obfuscate some JAR files from ${project.build.directory}/${project.build.finalName}/WEB-INF/lib before they are packaged into the WAR file by Spring Boot.

I can do it for the regular WAR file, but when Spring Boot Plugin repackages the application it creates a new WAR file and it seems to do a fresh copy of the JAR files instead of picking the obfuscated ones from ${project.build.directory}/${project.build.finalName}/WEB-INF/lib.

Any help would be greatly appreciated.

Regards

2

2 Answers

1
votes

As you suspected, Spring Boot uses a fresh copy of the jar files. There's no way to change that behaviour. I think your best bet may be to perform the obfuscation after the repackaging has been performed. You haven't said which obfuscation tool you're using, but Proguard can be run against an existing archive using its <injar> and <outjar> configuration settings.

0
votes

Finally I've come up with a simple solution. At the end of the package phase I run my obfuscation tool, e.g., Allatori, on the appropriate JAR files, then I use Exec Maven Plugin to update the WAR file built by Spring Boot Plugin (or by the WAR Plugin if you don't use Spring Boot Plugin) using the JAR executable as explained there.