Given a regular java gradle project, we have some entry main method which is defined in the jar manifest, and bunch of dependencies.
Now normally when we create a distribution we may use application plugin and have some structure like this as output
/bin (some splatform specific scripts that point to our jar)
/lib (our jar + all dependencies with their dependencies etc...)
Problem is that even though we used just few classes from our direct dependencies, they and all the transitive dependencies will end up in a distribution. For example from 100M of distribution only 1M is actually code that can possibly run and may have any relation to our application...
Tool like proguard can shrink code in a particular jar with various optimizations but it won't care if the code is unused. By unused i mean the main method is the entry point of the jar, and depending on the code in main it may never ever use majority of the code in the actual application jar and a lot more in library jars...
Our goal is to create this 1M jar that has only code that it actually will use, taking into consideration what is the main method in the jar manifest...
I've searched a lot but couldn't find any solution to this, proguard was very close, but i can't find any way to make it only care about specific flow of the code not all the code.
Are there any tools that can do this?