From f44e2a2e74968298e007517571bb687f14b6d957 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Wed, 30 Jan 2019 18:52:52 -0800 Subject: [PATCH] Clear compiler cache in clearCaches Resident compilation actually works pretty well most of the time*, but if there ever is an issue with the cached compilation, we should be able to easily clear the cache. * I've only had issues when package objects are involved --- main/src/main/scala/sbt/Main.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/src/main/scala/sbt/Main.scala b/main/src/main/scala/sbt/Main.scala index 8241d5b50..a2bcabeb5 100644 --- a/main/src/main/scala/sbt/Main.scala +++ b/main/src/main/scala/sbt/Main.scala @@ -837,6 +837,7 @@ object BuiltinCommands { } def registerCompilerCache(s: State): State = { + s.get(Keys.stateCompilerCache).foreach(_.clear()) val maxCompilers = System.getProperty("sbt.resident.limit") val cache = if (maxCompilers == null) @@ -875,7 +876,7 @@ object BuiltinCommands { def clearCaches: Command = { val help = Help.more(ClearCaches, ClearCachesDetailed) - Command.command(ClearCaches, help)(registerGlobalCaches) + Command.command(ClearCaches, help)(registerGlobalCaches _ andThen registerCompilerCache) } def shell: Command = Command.command(Shell, Help.more(Shell, ShellDetailed)) { s0 =>