@@ -213,7 +213,9 @@ object Build {
213213 // on a task. Instead, we make `compile` below depend on the bridge `packageSrc`
214214 Some ((artifactPath in (`dotty-sbt-bridge`, Compile , packageSrc)).value.toURI.toURL))),
215215 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,
217219
218220 // Use the same name as the non-bootstrapped projects for the artifacts
219221 moduleName ~= { _.stripSuffix(" -bootstrapped" ) },
@@ -747,18 +749,29 @@ object Build {
747749 // until sbt/sbt#2402 is fixed (https://github.com/sbt/sbt/issues/2402)
748750 lazy val cleanSbtBridge = TaskKey [Unit ](" cleanSbtBridge" , " delete dotty-sbt-bridge cache" )
749751
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+
750761 lazy val dottySbtBridgeSettings = Seq (
751762 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 := {
756766 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
760774 },
761- compile in Compile := (compile in Compile ).dependsOn(cleanSbtBridge).value,
762775 description := " sbt compiler bridge for Dotty" ,
763776 resolvers += Resolver .typesafeIvyRepo(" releases" ), // For org.scala-sbt:api
764777 libraryDependencies ++= Seq (
0 commit comments