Skip to content

Commit 2ff7e40

Browse files
automatically clean sbt cache for the dotty sbt bridge
1 parent 2359fb2 commit 2ff7e40

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

bridge/src/main/scala/xsbt/CompilerInterface.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ class CachedCompilerImpl(args: Array[String], output: Output, resident: Boolean)
5757
private[this] def run(sources: List[File], changes: DependencyChanges, callback: AnalysisCallback,
5858
log: Logger, delegate: Reporter, compileProgress: CompileProgress): Unit = {
5959
debug(log, args.mkString("Calling Dotty compiler with arguments (CompilerInterface):\n\t", "\n\t", ""))
60-
val ctx = (new ContextBase).initialCtx.fresh
61-
.setSbtCallback(callback)
62-
.setReporter(DelegatingReporter(delegate))
60+
val freshContext = (new ContextBase).initialCtx.fresh
61+
val ctx = freshContext.setSbtCallback(callback).setReporter(DelegatingReporter(delegate))
6362
val cl = getClass.getClassLoader.asInstanceOf[URLClassLoader]
6463

6564
val reporter = DottyMain.process(commandArguments(sources.toArray), ctx)

bridge/src/main/scala/xsbt/DelegatingReporter.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import core.Contexts._
1010

1111
import xsbti.Maybe
1212

13-
private object DelegatingReporter {
13+
object DelegatingReporter {
1414
def apply(delegate: xsbti.Reporter) = new DelegatingReporter(delegate)
1515
}
1616

17-
private final class DelegatingReporter(delegate: xsbti.Reporter) extends Reporter
17+
final class DelegatingReporter(delegate: xsbti.Reporter) extends Reporter
1818
with UniqueMessagePositions
1919
with HideNonSensicalMessages {
2020

@@ -38,7 +38,10 @@ private final class DelegatingReporter(delegate: xsbti.Reporter) extends Reporte
3838
def pointer(): xsbti.Maybe[Integer] = offset()
3939
def pointerSpace(): xsbti.Maybe[String] = Maybe.just(" " * pos.point)
4040
def sourceFile(): xsbti.Maybe[java.io.File] = maybe(file)
41-
def sourcePath(): xsbti.Maybe[String] = maybe(file.map(_.getPath))
41+
def sourcePath(): xsbti.Maybe[String] = {
42+
println(file)
43+
maybe(file.map(_.getPath))
44+
}
4245
}
4346

4447
delegate.log(position, d.message, severity)

project/Build.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
99

1010
object DottyBuild extends Build {
1111

12+
val cleanBridge = TaskKey[Unit]("clean-sbt-bridge", "delete dotty-sbt-bridge cache")
13+
1214
val baseVersion = "0.1"
1315
val isNightly = sys.env.get("NIGHTLYBUILD") == Some("yes")
1416

@@ -237,6 +239,25 @@ object DottyBuild extends Build {
237239
).
238240
settings(ScriptedPlugin.scriptedSettings: _*).
239241
settings(
242+
cleanBridge := {
243+
println("*** cleanBridge ***")
244+
val dottyBridgeVersion = version.value
245+
val dottyVersion = (version in dotty).value
246+
val classVersion = System.getProperty("java.class.version")
247+
val sbtV = sbtVersion.value
248+
val home = System.getProperty("user.home")
249+
val org = organization.value
250+
val artifact = moduleName.value
251+
252+
IO.delete(file(home) / ".ivy2" / "local" / "ch.epfl.lamp" / artifact)
253+
IO.delete(file(home) / ".ivy2" / "cache" / "org.scala-sbt" / s"$org-$artifact-$dottyBridgeVersion-bin_${dottyVersion}__$classVersion")
254+
IO.delete(file(home) / ".sbt" / "boot" / "scala-2.10.6" / "org.scala-sbt" / "sbt" / sbtV / s"$org-$artifact-$dottyBridgeVersion-bin_${dottyVersion}__$classVersion")
255+
},
256+
257+
ScriptedPlugin.scripted <<= ScriptedPlugin.scripted
258+
.dependsOn(publishLocal) // 2nd
259+
.dependsOn(cleanBridge), // 1st
260+
240261
ScriptedPlugin.scriptedLaunchOpts := Seq("-Xmx1024m"),
241262
ScriptedPlugin.scriptedBufferLog := false
242263
// TODO: Use this instead of manually copying DottyInjectedPlugin.scala

0 commit comments

Comments
 (0)