I have a library with a few dependencies, org.json...
# announcements
a
I have a library with a few dependencies, org.json for example. If I want to use this in other projects without specifying the dependencies there was well it looks like I need to create a "fat jar" that packages up everything. I did that via gradle using the line below but now it includes everything such as the kotlin stdlib which seems a bit unnecessary, is that required or a way to exclude it? I can see how it might be needed if you used this library in a pure java project or maybe its just best practice to have it all for version conflict issues, not sure what is best practice here. jar { from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }}
d
If you publish your library to a maven repository (or even just do a
project
dependency in Gradle) then you don't need to build a fat jar. fat jars are usually something that's done in applications to get a "one file to execute"-deal
👍 1
a
Thank you I think that answers my question, library should not be a fat jar and there are other methods of doing this.
g
In particular, if you publish your library on any Maven-style repository, the dependencies will also be published along with the (compiled) code
And when someone references your library using the typical Maven notation (
org.example:some-library:0.4.2
) their project will automatically look for the dependencies and add them using Gradle. You don't have to explicitly specify things like org.json for that to work