Empirically, the order of declared library dependencies in a build.sbt appears to matter. Is this true? If so, it is worth a brief mention in the sbt library management section of the documentation.
Yes, the order listed is the order used to resolve dependencies. This includes defaults if you merely append to defaults. Therefore you should put less likely candidates after more likely candidates. In the following example, the default resolvers are checked, then Sonatype snapshots, then dependencies only available on the local machine in the .m2
directory:
resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots"),
"Local .m2 Repository" at s"file:${ Path.userHome.absolutePath }/.m2/repository"
)
The defaults have changed over the years. To be certain you control the resolvers, another way to write this, without relying on defaults, is:
resolvers = Seq(
allResolvers,
Resolver.sonatypeRepo("snapshots"),
"Local .m2 Repository" at s"file:${ Path.userHome.absolutePath }/.m2/repository"
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With