[proguard] Warning: there were 184 classes in incorrectly named files.
[proguard] You should make sure all file names correspond to their class names.
[proguard] The directory hierarchies must correspond to the package hierarchies.
[proguard] (http://proguard.sourceforge.net/manual/troubleshooting.html#unexpectedclass)
[proguard] If you don't mind the mentioned classes not being written out,
[proguard] you could try your luck using the '-ignorewarnings' option.
[proguard] Error: Please correct the above warnings first.
Spring boot seem to compile my class files into a folder named BOOT-INF/classes Which defers from the original directory structure. What is the best way to correct this problem?
I had the same problem, and this SO question is the first result that came. So it may be worth linking to the original solution. The reason for that behaviour is explained here :
ProGuard requires that the names of the class files in a jar file correspond directly to the names of the classes, without a prefix like "BOOT-INF/classes".
A way to solve this is to extract the jar, apply Proguard on it and then pack the obfuscated classes into a new jar.
The same post goes on with :
Spring Boot basically requires three directories, BOOT-INF, META-INF and org. Obfuscation of your own classes and repacking to a fat jar can be roughly done the following way:
# Extract the unobfuscated fat jar from Spring Boot
jar xvf input.jar
# Execute ProGuard, as input for ProGuard use
# -injars BOOT-INF/classes/
java -jar proguard.jar @ proguard.conf
# If you also want to obfuscate the libs, add
# -injars BOOT-INF/lib
# Be aware, probably needs filtering, if some but not all libs should be obfuscated. I have not tested, but I believe the Spring Framwork libraries should not be obfuscated because they would require a lot of keep exceptions in the ProGuard configuration.
# If some of the libs should be used for obfuscation in the copy step below **remove** the libs before copying, otherwise the old files remain in the fat jar.
# Copy the old files excluding the classes to a new directory.
# First, the classes are stored here:
mkdir obfuscated/BOOT-INF
mkdir obfuscated/BOOT-INF/classes
# I assume the output is obfuscated-classes.jar
# It has to be extracted in the new output
cp obfuscated-classes.jar obfuscated/BOOT-INF/classes
pushd obfuscated/BOOT-INF/classes
jar xvf obfuscated-classes.jar
rm obfuscated-classes.jar
popd
# Copy the remaining files
boot_directories=(BOOT-INF/lib META-INF org)
for boot_directory in ${boot_directories[@]}; do
mkdir -p "./obfuscated/$boot_directory"
copy_command="cp -R ./$boot_directory/* ./obfuscated/$boot_directory/"
eval $copy_command
done
# Finally, create a new jar
pushd obfuscated
# Be aware: do not use * as selector, the order of the entries in the resulting jar is important!
jar c0mf ./META-INF/MANIFEST.MF input-obfuscated.jar BOOT-INF/classes/ BOOT-INF/lib/ META-INF/ org/
popd
# Now, there is a jar obfuscated/input-obfuscated.jar that is a Spring Boot fat jar whose BOOT-INF/classes directory is obfuscated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With