I made once a maven plugin which reprocesses jar files.
It allows to remove extra content such as comments and directories.
In addition, it handles nested zip files to increase their compress-ability.
And all the features can be toggled individually.
There is a maintained fork of this called jd-gui-duo which includes more features and more decompilers (JADX, Vineflower, Fernflower, CFR, Procyon, ...)
I created once a maven plugin to recompress Java artefacts with zopfli. I rewrote it in Java and runs entirely in the JVM. This means, the speed is worse and may contain bugs:
https://luccappellaro.github.io/2015/03/01/ZopfliMaven.html