From 33514ab6d741d5a87f7d16dc53437cf405ebaa85 Mon Sep 17 00:00:00 2001 From: Grzegorz Kossakowski Date: Fri, 8 Nov 2013 11:29:17 +0100 Subject: [PATCH] Recover from class files and Analysis object getting out of sync. The #958 describes a scenario where partially successful results are produced in form of class files written to disk. However, if compilation fails down the road we do not record any new compilation results (products) in Analysis object. This leads to Analysis object and disk contents to get out of sync. One way to solve this problem is to use transactional ClassfileManager that commits changes to class files on disk only when entire incremental compilation session is successful. Otherwise, new class files are rolled back to previous state. The other way to solve this problem is to record time stamps of class files in Analysis object. This way, incremental compiler can detect that class files and Analysis object got out of sync and recover from that by recompiling corresponding sources. This commit uses latter solution which enables simpler (non-transactional) ClassfileManager to handle scenario from #958. Fixes #958 --- compile/inc/src/main/scala/sbt/inc/Compile.scala | 2 +- .../compiler-project/error-in-invalidated/{pending => test} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename sbt/src/sbt-test/compiler-project/error-in-invalidated/{pending => test} (100%) diff --git a/compile/inc/src/main/scala/sbt/inc/Compile.scala b/compile/inc/src/main/scala/sbt/inc/Compile.scala index ce1803ccc..7b36b8b97 100644 --- a/compile/inc/src/main/scala/sbt/inc/Compile.scala +++ b/compile/inc/src/main/scala/sbt/inc/Compile.scala @@ -19,7 +19,7 @@ object IncrementalCompile output: Output, log: Logger, options: IncOptions): (Boolean, Analysis) = { - val current = Stamps.initial(Stamp.exists, Stamp.hash, Stamp.lastModified) + val current = Stamps.initial(Stamp.lastModified, Stamp.hash, Stamp.lastModified) val internalMap = (f: File) => previous.relations.produced(f).headOption val externalAPI = getExternalAPI(entry, forEntry) try { diff --git a/sbt/src/sbt-test/compiler-project/error-in-invalidated/pending b/sbt/src/sbt-test/compiler-project/error-in-invalidated/test similarity index 100% rename from sbt/src/sbt-test/compiler-project/error-in-invalidated/pending rename to sbt/src/sbt-test/compiler-project/error-in-invalidated/test