I am currently working on a project that results in a fat JAR that runs in an OSGi context (Apache Felix). Is there a way/command to check if some of the jars that I have embedded into my fat jar are also available from other bundles and services, so that I can remove them (and thus make the fat jar smaller)?
The reason why I am building a fat jar is because I am using a different build system to build my jar. (I am using Scala & SBT, everything else is is built with Java & Gradle)
I do not know of any automated tools doing this, but Apache Felix has two tools that might help you find your duplicates:
/system/console/depfinder
/system/console/status-duplicate_exports
Especially, the second one should help you. It lists packages that are exported more than once and then it lists the bundles that export the those packages. If your bundle appears in this list, you know that another bundle exports packages, that are in your fat bundle.
But as with the depfinder
, you will have to go through the list manually or write a little script to help you.