From b11170462025db6c7d8767b6c98fc04f3e78c213 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 11 Aug 2020 02:10:40 -0400 Subject: [PATCH] Move Coursier cache check --- main/src/main/scala/sbt/MainLoop.scala | 4 ---- main/src/main/scala/sbt/coursierint/LMCoursier.scala | 10 +++++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/main/src/main/scala/sbt/MainLoop.scala b/main/src/main/scala/sbt/MainLoop.scala index 7bcea26ce..62c7ff285 100644 --- a/main/src/main/scala/sbt/MainLoop.scala +++ b/main/src/main/scala/sbt/MainLoop.scala @@ -32,10 +32,6 @@ object MainLoop { /** Entry point to run the remaining commands in State with managed global logging.*/ def runLogged(state: State): xsbti.MainResult = { - // This warns if ~/.coursier/cache is found. - // Temporary, remove when updating coursier to 2.0.0 final. - lmcoursier.CoursierConfiguration.checkLegacyCache() - // We've disabled jline shutdown hooks to prevent classloader leaks, and have been careful to always restore // the jline terminal in finally blocks, but hitting ctrl+c prevents finally blocks from being executed, in that // case the only way to restore the terminal is in a shutdown hook. diff --git a/main/src/main/scala/sbt/coursierint/LMCoursier.scala b/main/src/main/scala/sbt/coursierint/LMCoursier.scala index 5c4b950f9..0cfe91fc9 100644 --- a/main/src/main/scala/sbt/coursierint/LMCoursier.scala +++ b/main/src/main/scala/sbt/coursierint/LMCoursier.scala @@ -37,10 +37,18 @@ object LMCoursier { private[this] val credentialRegistry: ConcurrentHashMap[(String, String), IvyCredentials] = new ConcurrentHashMap + private[this] lazy val checkLegacyCache: Unit = { + // This warns if ~/.coursier/cache is found. + // Temporary, remove when updating coursier to 2.0.0 final. + lmcoursier.CoursierConfiguration.checkLegacyCache() + } + def defaultCacheLocation: File = sys.props.get("sbt.coursier.home") match { case Some(home) => new File(home).getAbsoluteFile / "cache" - case _ => CoursierDependencyResolution.defaultCacheLocation + case _ => + checkLegacyCache + CoursierDependencyResolution.defaultCacheLocation } def relaxedForAllModules: Seq[(ModuleMatchers, Reconciliation)] =