@@ -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" ) },
@@ -747,18 +749,29 @@ object Build {
747
749
// until sbt/sbt#2402 is fixed (https://github.com/sbt/sbt/issues/2402)
748
750
lazy val cleanSbtBridge = TaskKey [Unit ](" cleanSbtBridge" , " delete dotty-sbt-bridge cache" )
749
751
752
+ def cleanSbtBridgeImpl (): Unit = {
753
+ val home = System .getProperty(" user.home" )
754
+ val sbtOrg = " org.scala-sbt"
755
+ val bridgePattern = s " *dotty-sbt-bridge* $dottyVersion* "
756
+
757
+ IO .delete((file(home) / " .sbt" / " 1.0" / " zinc" / sbtOrg * bridgePattern).get)
758
+ IO .delete((file(home) / " .sbt" / " boot" * " scala-*" / sbtOrg / " sbt" * " *" * bridgePattern).get)
759
+ }
760
+
750
761
lazy val dottySbtBridgeSettings = Seq (
751
762
cleanSbtBridge := {
752
- val home = System .getProperty(" user.home" )
753
- val sbtOrg = " org.scala-sbt"
754
- val bridgeDirectoryPattern = s " * $dottyVersion* "
755
-
763
+ cleanSbtBridgeImpl()
764
+ },
765
+ compile in Compile := {
756
766
val log = streams.value.log
757
- log.info(" Cleaning the dotty-sbt-bridge cache" )
758
- IO .delete((file(home) / " .ivy2" / " cache" / sbtOrg * bridgeDirectoryPattern).get)
759
- IO .delete((file(home) / " .sbt" / " boot" * " scala-*" / sbtOrg / " sbt" * " *" * bridgeDirectoryPattern).get)
767
+ val prev = (previousCompile in Compile ).value.analysis.orElse(null )
768
+ val cur = (compile in Compile ).value
769
+ if (prev != cur) {
770
+ log.info(" Cleaning the dotty-sbt-bridge cache because it was recompiled." )
771
+ cleanSbtBridgeImpl()
772
+ }
773
+ cur
760
774
},
761
- compile in Compile := (compile in Compile ).dependsOn(cleanSbtBridge).value,
762
775
description := " sbt compiler bridge for Dotty" ,
763
776
resolvers += Resolver .typesafeIvyRepo(" releases" ), // For org.scala-sbt:api
764
777
libraryDependencies ++= Seq (
0 commit comments