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?
sbt resolver is the configuration for repository that contains jars and their dependencies. for example the below is a resolver definition for a repository called Sonatype and it points at snapshot releases (dev versions) resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
By default, sbt uses the standard Ivy home directory location ${user. home}/. ivy2/ . This can be configured machine-wide, for use by both the sbt launcher and by projects, by setting the system property sbt.
Background. update resolves dependencies according to the settings in a build file, such as libraryDependencies and resolvers . Other tasks use the output of update (an UpdateReport ) to form various classpaths. Tasks that in turn use these classpaths, such as compile or run , thus indirectly depend on update .
sbt provides an interface to the repository types available in Ivy: file, URL, SSH, and SFTP. A key feature of repositories in Ivy is using patterns to configure repositories.
Another even more elegant solution would be to investigate the SBT sources if it is easily possible to setup this behavior as a separate task. The necessary steps could be the same as in my other answer.
sbt.ivy.home
from update
task and provide a parameterized overload for it (if this is possible)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.
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