Fix csrCacheDirectory and add test

This commit is contained in:
Adrien Piquerez 2024-10-14 13:28:46 +02:00
parent 9517813190
commit c82f13c2db
3 changed files with 16 additions and 1 deletions

View File

@ -3373,7 +3373,7 @@ object Classpaths {
val ac = appConfiguration.value
val ip = ivyPaths.value
// if ivyPaths is customized, create coursier-cache directory in it
val defaultIvyCache = bootIvyHome(ac)
val defaultIvyCache = bootIvyHome(ac).map(_.toString)
if (old != LMCoursier.defaultCacheLocation) old
else if (ip.ivyHome == defaultIvyCache) old
else

View File

@ -0,0 +1,12 @@
TaskKey[Unit]("checkIsDefaultCache") := {
val csrCacheDir = csrCacheDirectory.value
assert(csrCacheDir == sbt.coursierint.LMCoursier.defaultCacheLocation, csrCacheDir.toString)
val expectedPath = if Util.isWindows then "Coursier\\Cache\\v1" else ".cache/coursier/v1"
assert(csrCacheDir.toString.endsWith(expectedPath), csrCacheDir.toString)
}
TaskKey[Unit]("checkIsCustomCache") := {
val csrCacheDir = csrCacheDirectory.value
val ip = ivyPaths.value
assert(csrCacheDir == file(ip.ivyHome.get) / "coursier-cache", csrCacheDir.toString)
}

View File

@ -0,0 +1,3 @@
> checkIsDefaultCache
> 'set ivyPaths := ivyPaths.value.withIvyHome("ivy-cache")'
> checkIsCustomCache