@@ -213,7 +213,9 @@ object Build {
213
213
// on a task. Instead, we make `compile` below depend on the bridge `packageSrc`
214
214
Some ((artifactPath in (`dotty-sbt-bridge`, Compile , packageSrc)).value.toURI.toURL))),
215
215
compile in Compile := (compile in Compile )
216
- .dependsOn(packageSrc in (`dotty-sbt-bridge`, Compile )).value,
216
+ .dependsOn(packageSrc in (`dotty-sbt-bridge`, Compile ))
217
+ .dependsOn(compile in (`dotty-sbt-bridge`, Compile ))
218
+ .value,
217
219
218
220
// Use the same name as the non-bootstrapped projects for the artifacts
219
221
moduleName ~= { _.stripSuffix(" -bootstrapped" ) },
@@ -746,18 +748,29 @@ object Build {
746
748
// until sbt/sbt#2402 is fixed (https://github.com/sbt/sbt/issues/2402)
747
749
lazy val cleanSbtBridge = TaskKey [Unit ](" cleanSbtBridge" , " delete dotty-sbt-bridge cache" )
748
750
751
+ def cleanSbtBridgeImpl (): Unit = {
752
+ val home = System .getProperty(" user.home" )
753
+ val sbtOrg = " org.scala-sbt"
754
+ val bridgePattern = s " *dotty-sbt-bridge* $dottyVersion* "
755
+
756
+ IO .delete((file(home) / " .sbt" / " 1.0" / " zinc" / sbtOrg * bridgePattern).get)
757
+ IO .delete((file(home) / " .sbt" / " boot" * " scala-*" / sbtOrg / " sbt" * " *" * bridgePattern).get)
758
+ }
759
+
749
760
lazy val dottySbtBridgeSettings = Seq (
750
761
cleanSbtBridge := {
751
- val home = System .getProperty(" user.home" )
752
- val sbtOrg = " org.scala-sbt"
753
- val bridgeDirectoryPattern = s " * $dottyVersion* "
754
-
762
+ cleanSbtBridgeImpl()
763
+ },
764
+ compile in Compile := {
755
765
val log = streams.value.log
756
- log.info(" Cleaning the dotty-sbt-bridge cache" )
757
- IO .delete((file(home) / " .ivy2" / " cache" / sbtOrg * bridgeDirectoryPattern).get)
758
- IO .delete((file(home) / " .sbt" / " boot" * " scala-*" / sbtOrg / " sbt" * " *" * bridgeDirectoryPattern).get)
766
+ val prev = (previousCompile in Compile ).value.analysis.orElse(null )
767
+ val cur = (compile in Compile ).value
768
+ if (prev != cur) {
769
+ log.info(" Cleaning the dotty-sbt-bridge cache because it was recompiled." )
770
+ cleanSbtBridgeImpl()
771
+ }
772
+ cur
759
773
},
760
- compile in Compile := (compile in Compile ).dependsOn(cleanSbtBridge).value,
761
774
description := " sbt compiler bridge for Dotty" ,
762
775
resolvers += Resolver .typesafeIvyRepo(" releases" ), // For org.scala-sbt:api
763
776
libraryDependencies ++= Seq (
0 commit comments