Skip to content

Commit 2d1ed0b

Browse files
committed
Detect and handle deletion of previously downloaded dependencies from ~/.m2 more gracefully. (relates to #146)
1 parent 78d95e8 commit 2d1ed0b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/kotlin/kscript/app/DependencyUtil.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ fun resolveDependencies(depIds: List<String>, customRepos: List<MavenRepo> = emp
2727
.associateBy({ it.split(" ")[0] }, { it.split(" ")[1] })
2828

2929
if (cache.containsKey(depsHash)) {
30-
return cache.get(depsHash)
30+
val cachedCP = cache.get(depsHash)!!
31+
32+
33+
// Make sure that local dependencies have not been wiped since resolving them (like by deleting .m2) (see #146)
34+
if (cachedCP.split(":").all { File(it).exists() }) {
35+
return cachedCP
36+
} else {
37+
System.err.println("[kscript] Detected missing dependencies in cache.")
38+
}
3139
}
3240
}
3341

0 commit comments

Comments
 (0)