I'm trying to generate two different jars from a project which is a monorepo that includes dependencies to many many great things in this world, so needless to say i do not want these executable jars to have big sizes and would rather have them include only classes that they actually use.
I followed instructions here https://imperceptiblethoughts.com/shadow/configuration/minimizing/
.
In order to test if shadowJar
task actually works i created a simple Main java file that practically uses nothing other than java SDK.
public class Main {
public static void main(String[] args) {
System.out.println("client");
}
}
and added the actual shadow jar task and pointed to this as a main class
shadowJar {
archiveBaseName.set('client')
archiveClassifier.set('')
archiveVersion.set('0.1')
minimize()
manifest {
attributes 'Main-Class': 'my.package.Main'
}
}
which generates the uber jar correctly (i was able to run it simply with java -jar ...
), however the size of the file is 10Mb.
then i generated a new version without minimize()
part and it was 15Mb.
Is there something i do wrong here? Maybe i'm expecting too much from this tool and proguard (as tedious as it is to setup) is the only way?