What dependency scope is recommended in maven when...
# announcements
What dependency scope is recommended in maven when creating a kotlin library? I thought provided scope made sense to avoid messing with the version of who is implementing. But on github I see most of them use compile scope
will not pull the dependency transitively, i.e. if someone uses your lib but not the one that you specify as
, it will not be available in runtime. On the other hand if you use
then the library will be fetched, even if someone doesn’t declare it explicitly. Since most dependencies are in fact required by the libraries, specifying
would be pretty annoying (imagine every library required all of their dependencies to be declared explicitly. That would also mean dependencies of the dependencies and so on). I don’t think you need to be concerned about messing with the versions: higher version will be pulled automatically, and if someone needs some specific version then there’s plenty of options in Gradle to pin dependencies to versions. Most libraries follow SemVer so it’s not a very popular problem that something breaks because a dependency updated dependency, imo
At least as a library consumer I very rarely have a problem with dependencies pulling other dependencies
I frequently run into transitive dependency mismatch issues, but the 'solution' isn't to avoid declaring the dependency by using provided. As a library author, one should explicitly use the dependencies exactly as tested (via compile, or in gradle api) Consumers of libraries are better suited to make dependency resolution choices if needed as their application is the one that needs to work properly with ALL dependencies combined, the 'right' choice, if not automatically determined is certainly not obvious to the library author.