Skip to content

Commit e77a47f

Browse files
authored
Merge pull request #5128 from dotty-staging/recover-launchIDE
Release sbt-dotty 0.2.3 with a launchIDE that can run even with errors, and less warnings from sbt
2 parents 7a42360 + b29e9d2 commit e77a47f

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ object Build {
5656

5757
val sbtDottyName = "sbt-dotty"
5858
val sbtDottyVersion = {
59-
val base = "0.2.3"
59+
val base = "0.2.4"
6060
if (isRelease) base else base + "-SNAPSHOT"
6161
}
6262

sbt-dotty/src/dotty/tools/sbtplugin/DottyIDEPlugin.scala

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ object DottyIDEPlugin extends AutoPlugin {
170170
override def requires: Plugins = plugins.JvmPlugin
171171
override def trigger = allRequirements
172172

173+
private val artifactFile = new File(".dotty-ide-artifact")
174+
private val configFile = new File(".dotty-ide.json")
175+
173176
def configureIDE = Command.command("configureIDE") { origState =>
174177
val (dottyVersion, projRefs, dottyState) = dottySetup(origState)
175178
val configs0 = runInAllIDEConfigurations(projectConfig, projRefs, dottyState).flatten
@@ -184,7 +187,7 @@ object DottyIDEPlugin extends AutoPlugin {
184187
val dlsVersion = dottyVersion
185188
.replace("-nonbootstrapped", "") // The language server is only published bootstrapped
186189
val dlsBinaryVersion = dlsVersion.split("\\.").take(2).mkString(".")
187-
val pwArtifact = new PrintWriter(".dotty-ide-artifact")
190+
val pwArtifact = new PrintWriter(artifactFile)
188191
try {
189192
pwArtifact.println(s"ch.epfl.lamp:dotty-language-server_${dlsBinaryVersion}:${dlsVersion}")
190193
} finally {
@@ -193,7 +196,7 @@ object DottyIDEPlugin extends AutoPlugin {
193196

194197
val mapper = new ObjectMapper
195198
mapper.writerWithDefaultPrettyPrinter()
196-
.writeValue(new File(".dotty-ide.json"), configs.toArray)
199+
.writeValue(configFile, configs.toArray)
197200

198201
origState
199202
}
@@ -205,6 +208,23 @@ object DottyIDEPlugin extends AutoPlugin {
205208
origState
206209
}
207210

211+
def launchIDE = Command.command("launchIDE") { state0 =>
212+
val state1 = try {
213+
Command.process("configureIDE", state0)
214+
} catch {
215+
case i: Incomplete =>
216+
if (artifactFile.exists && configFile.exists) {
217+
state0.log.error("IDE configuration failed, launching the IDE using the previous configuration")
218+
state0: State
219+
} else {
220+
state0.log.error("IDE configuration failed and no previous configuration found")
221+
state0.log.error("Please fix the compilation errors then run 'launchIDE' again")
222+
throw i
223+
}
224+
}
225+
Command.process("runCode", state1)
226+
}
227+
208228
private def projectConfigTask(config: Configuration): Initialize[Task[Option[ProjectConfig]]] = Def.taskDyn {
209229
if ((sources in config).value.isEmpty) Def.task { None }
210230
else Def.task {
@@ -240,7 +260,7 @@ object DottyIDEPlugin extends AutoPlugin {
240260
)
241261

242262
override def buildSettings: Seq[Setting[_]] = Seq(
243-
commands ++= Seq(configureIDE, compileForIDE),
263+
commands ++= Seq(configureIDE, compileForIDE, launchIDE),
244264

245265
excludeFromIDE := false,
246266

sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,28 @@ object DottyPlugin extends AutoPlugin {
194194
} else {
195195
Def.task { si }
196196
}
197-
}.value
197+
}.value,
198+
199+
scalaModuleInfo := {
200+
val old = scalaModuleInfo.value
201+
if (isDotty.value) {
202+
// Turns off the warning:
203+
// [warn] Binary version (0.9.0-RC1) for dependency ...;0.9.0-RC1
204+
// [warn] in ... differs from Scala binary version in project (0.9).
205+
old.map(_.withCheckExplicit(false))
206+
} else old
207+
},
208+
209+
updateOptions := {
210+
val old = updateOptions.value
211+
if (isDotty.value) {
212+
// Turn off the warning:
213+
// circular dependency found:
214+
// ch.epfl.lamp#scala-library;0.9.0-RC1->ch.epfl.lamp#dotty-library_0.9;0.9.0-RC1->...
215+
// (This should go away once we merge dotty-library and scala-library in one artefact)
216+
old.withCircularDependencyLevel(sbt.librarymanagement.ivy.CircularDependencyLevel.Ignore)
217+
} else old
218+
}
198219
)
199220
}
200221

0 commit comments

Comments
 (0)