From 5d8b94de55f3b9526e6ea9e7fea655a8b243de33 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Sat, 5 Oct 2019 16:39:23 -0700 Subject: [PATCH] Clean ivy resolution cache before regular clean The way clean was implemented, it was running `clean`, `ivyModule` and `streams` concurrently. This was problematic because clean could blow away files needed by `ivyModule` and `streams`. To fix this, move the cleanCachedResolutionCache into a separate task and run that before the normal clean. Should fix https://github.com/sbt/sbt/issues/5067. --- main/src/main/scala/sbt/Defaults.scala | 6 ++---- main/src/main/scala/sbt/Keys.scala | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index b9eb595c6..3b47bf390 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -484,10 +484,8 @@ object Defaults extends BuildCommon { sbtPlugin.value, crossPaths.value ), - clean := { - val _ = clean.value - IvyActions.cleanCachedResolutionCache(ivyModule.value, streams.value.log) - }, + cleanIvy := IvyActions.cleanCachedResolutionCache(ivyModule.value, streams.value.log), + clean := clean.dependsOn(cleanIvy).value, scalaCompilerBridgeBinaryJar := None, scalaCompilerBridgeSource := ZincLmUtil.getDefaultBridgeModule(scalaVersion.value), ) diff --git a/main/src/main/scala/sbt/Keys.scala b/main/src/main/scala/sbt/Keys.scala index ae957c369..e02685a47 100644 --- a/main/src/main/scala/sbt/Keys.scala +++ b/main/src/main/scala/sbt/Keys.scala @@ -195,6 +195,7 @@ object Keys { val semanticdbOptions = settingKey[Seq[String]]("The Scalac options introduced for SemanticDB").withRank(CSetting) val clean = taskKey[Unit]("Deletes files produced by the build, such as generated sources, compiled classes, and task caches.").withRank(APlusTask) + private[sbt] val cleanIvy = taskKey[Unit]("Deletes the ivy cached resolution") val console = taskKey[Unit]("Starts the Scala interpreter with the project classes on the classpath.").withRank(APlusTask) val consoleQuick = TaskKey[Unit]("consoleQuick", "Starts the Scala interpreter with the project dependencies on the classpath.", ATask, console) val consoleProject = taskKey[Unit]("Starts the Scala interpreter with the sbt and the build definition on the classpath and useful imports.").withRank(AMinusTask)