EECOLOR EECOLOR - 3 months ago 22
Scala Question

How to test sbt resolvers

On my local machine I have an ivy cache that has been filled by working on multiple projects.

A library

X
is loaded using resolver
Y
in project
A
. This same library
X
is used in project
B
, no problems resolving this library because it's in my local cache.

When one of my colleagues loads project
B
he get's the error that library
X
could not be resolved. The problem: resolver
Y
is missing.

How can I test if my sbt project has a complete set of resolvers to resolve all dependencies without removing my ivy cache?

Answer

This command allows you to find if you are missing any updates for the current project. Note that this will not discover any missing resolvers for your plugins.

commands += Command.command("testUpdate") { state =>
  val base = baseDirectory.value
  val newState = Project
    .extract(state)
    .append(Seq(ivyPaths := new IvyPaths(base, Some(base / "tmp-cache"))), state)
  val (s, _) = Project
    .extract(newState)
    .runTask(update, newState)
  s
}

It could be expanded by removing the directory afterwards.