How to check sbt resolvers

On my local machine, I have an ivy cache that has been filled with work on several projects.

The X library is loaded using resolver Y in project A The same X library is used in project B , resolving this library without problems, because it is in my local cache.

When one of my colleagues loads project B , he gets an error that library X could not resolve. Problem: resolver Y missing.

How can I check if my sbt project has a full set of permissions to resolve all dependencies without deleting my ivy cache?

+7
scala sbt
source share
4 answers

This command allows you to find if there are not enough updates for the current project. Please note that this will not detect missing permissions 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 can be expanded by deleting the directory afterwards.

+2
source share

Another even more elegant solution would be to explore the sources of SBT if it is easy to configure this behavior as a separate task. The necessary steps may be the same as in my other answer .

  • Extract the sbt.ivy.home parameter from the update task and provide a parameterized overload for it (if possible)
  • Defining a new testDependencies task see documentation
  • Create tempDirectory
  • Call Update (tempDirectory)
  • Gather Results
  • Delete tempDirectory
  • Promote Results
  • Provide a transfer request;) or sbt plugin
+2
source share

I found, admittedly, a simple, but slightly hacked and yet working solution. As described here , you can customize your ivy home directory. Once configured, this will invoke sbt instances on your system to update all dependencies, due to the new cache directory. When all dependencies can be resolved, you can check std out for some string indicating success. For example, Done updating. and then delete the temporary folder. Caution, a new solution from scratch may take some time! ~ 5 minutes 100 Mbps and using an SSD drive

Instead of defining the system sbt.ivy.home variable latitudinally and somewhat not portable, I would recommend using a less systemic invasive option to define the sbt.ivy.home variable in the sbt.ivy.home environment SBT_OPTS in your local command / terminal session. On Windows, this looks like this way:

 C:\Users\isi\Projects\learning\sbt-test-dependencies>SET SBT_OPTS=-Dsbt.ivy.home="C:\path\to\your\temp\directory" C:\Users\isi\Projects\learning\sbt-test-dependencies>sbt Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0 [info] Loading project definition from C:\Users\isi\Projects\learning\sbt-test-dependencies\project [info] Updating {file:/C:/Users/isi/Projects/learning/sbt-test-dependencies/project/}sbt-test-dependencies-build... [info] Resolving org.fusesource.jansi#jansi;1.4 ... [info] downloading https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.typesafe.sbteclipse/sbteclipse-plugin/scala_2.10/sbt_0.13/4.0.0/jars/sbteclipse-plugin.jar ... [info] [SUCCESSFUL ] com.typesafe.sbteclipse#sbteclipse-plugin;4.0.0!sbteclipse-plugin.jar (4783ms) ... [info] downloading https://jcenter.bintray.com/org/scala-lang/jline/2.10.5/jline-2.10.5.jar ... [info] [SUCCESSFUL ] org.scala-lang#jline;2.10.5!jline.jar (419ms) [info] downloading https://jcenter.bintray.com/org/fusesource/jansi/jansi/1.4/jansi-1.4.jar ... [info] [SUCCESSFUL ] org.fusesource.jansi#jansi;1.4!jansi.jar (325ms) [info] Done updating. [info] Set current project to sbt-test-dependencies (in build file:/C:/Users/isi/Projects/learning/sbt-test-dependencies/)/Users/isi/Projects/learning/sbt-test-dependencies/) 

The output signal can be transmitted over channels to say grep , and the output code can be used for further processing. Please note that the console output above was created using the sbt interactive command, a similar output is created using the non-interactive sbt update command.

+1
source share

An available SBT plugin, called SBT dirty money , is now available to add additional features to solve this problem. Although you need to execute an additional command.

+1
source share

All Articles