Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are sbt library dependencies order dependent?

Tags:

sbt

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.

like image 917
Traveler Avatar asked Mar 19 '15 01:03

Traveler


1 Answers

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"
)
like image 155
Mike Slinn Avatar answered Oct 20 '22 23:10

Mike Slinn