From c0c6b06eb35fb0ad221c321ddb9cc57683d2e123 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Wed, 19 Sep 2018 21:03:49 +0200 Subject: [PATCH 1/3] sbt launchIDE: launch even if there are compilation errors ...assuming that existing configuration files exist. Note that this won't work in the build of Dotty itself because `runCode` is overriden to run dotty-language-server, and this won't work if dotty-language-server's dependencies cannot be compiled. --- .../tools/sbtplugin/DottyIDEPlugin.scala | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/sbt-dotty/src/dotty/tools/sbtplugin/DottyIDEPlugin.scala b/sbt-dotty/src/dotty/tools/sbtplugin/DottyIDEPlugin.scala index b78e0fa45f68..5df06e48ca68 100644 --- a/sbt-dotty/src/dotty/tools/sbtplugin/DottyIDEPlugin.scala +++ b/sbt-dotty/src/dotty/tools/sbtplugin/DottyIDEPlugin.scala @@ -170,6 +170,9 @@ object DottyIDEPlugin extends AutoPlugin { override def requires: Plugins = plugins.JvmPlugin override def trigger = allRequirements + private val artifactFile = new File(".dotty-ide-artifact") + private val configFile = new File(".dotty-ide.json") + def configureIDE = Command.command("configureIDE") { origState => val (dottyVersion, projRefs, dottyState) = dottySetup(origState) val configs0 = runInAllIDEConfigurations(projectConfig, projRefs, dottyState).flatten @@ -184,7 +187,7 @@ object DottyIDEPlugin extends AutoPlugin { val dlsVersion = dottyVersion .replace("-nonbootstrapped", "") // The language server is only published bootstrapped val dlsBinaryVersion = dlsVersion.split("\\.").take(2).mkString(".") - val pwArtifact = new PrintWriter(".dotty-ide-artifact") + val pwArtifact = new PrintWriter(artifactFile) try { pwArtifact.println(s"ch.epfl.lamp:dotty-language-server_${dlsBinaryVersion}:${dlsVersion}") } finally { @@ -193,7 +196,7 @@ object DottyIDEPlugin extends AutoPlugin { val mapper = new ObjectMapper mapper.writerWithDefaultPrettyPrinter() - .writeValue(new File(".dotty-ide.json"), configs.toArray) + .writeValue(configFile, configs.toArray) origState } @@ -205,6 +208,23 @@ object DottyIDEPlugin extends AutoPlugin { origState } + def launchIDE = Command.command("launchIDE") { state0 => + val state1 = try { + Command.process("configureIDE", state0) + } catch { + case i: Incomplete => + if (artifactFile.exists && configFile.exists) { + state0.log.error("IDE configuration failed, launching the IDE using the previous configuration") + state0: State + } else { + state0.log.error("IDE configuration failed and no previous configuration found") + state0.log.error("Please fix the compilation errors then run 'launchIDE' again") + throw i + } + } + Command.process("runCode", state1) + } + private def projectConfigTask(config: Configuration): Initialize[Task[Option[ProjectConfig]]] = Def.taskDyn { if ((sources in config).value.isEmpty) Def.task { None } else Def.task { @@ -240,7 +260,7 @@ object DottyIDEPlugin extends AutoPlugin { ) override def buildSettings: Seq[Setting[_]] = Seq( - commands ++= Seq(configureIDE, compileForIDE), + commands ++= Seq(configureIDE, compileForIDE, launchIDE), excludeFromIDE := false, From 570497bf359194c92bad7fec90f667ad977685f0 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Tue, 18 Sep 2018 16:24:13 +0200 Subject: [PATCH 2/3] Turn off annoying sbt warnings --- .../dotty/tools/sbtplugin/DottyPlugin.scala | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala b/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala index b4c0c395f40e..c00df73c1f63 100644 --- a/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala +++ b/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala @@ -194,7 +194,28 @@ object DottyPlugin extends AutoPlugin { } else { Def.task { si } } - }.value + }.value, + + scalaModuleInfo := { + val old = scalaModuleInfo.value + if (isDotty.value) { + // Turns off the warning: + // [warn] Binary version (0.9.0-RC1) for dependency ...;0.9.0-RC1 + // [warn] in ... differs from Scala binary version in project (0.9). + old.map(_.withCheckExplicit(false)) + } else old + }, + + updateOptions := { + val old = updateOptions.value + if (isDotty.value) { + // Turn off the warning: + // circular dependency found: + // ch.epfl.lamp#scala-library;0.9.0-RC1->ch.epfl.lamp#dotty-library_0.9;0.9.0-RC1->... + // (This should go away once we merge dotty-library and scala-library in one artefact) + old.withCircularDependencyLevel(sbt.librarymanagement.ivy.CircularDependencyLevel.Ignore) + } else old + } ) } From b29e9d21b533b88ff9f221949a0de50b387354ed Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Wed, 19 Sep 2018 22:29:25 +0200 Subject: [PATCH 3/3] sbt-dotty: Bump to 0.2.4-SNAPSHOT 0.2.3 has been released. --- project/Build.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Build.scala b/project/Build.scala index 69bab9395a4f..d706a5a26248 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -56,7 +56,7 @@ object Build { val sbtDottyName = "sbt-dotty" val sbtDottyVersion = { - val base = "0.2.3" + val base = "0.2.4" if (isRelease) base else base + "-SNAPSHOT" }