Skip to content

Release sbt-dotty 0.2.3 with a launchIDE that can run even with errors, and less warnings from sbt #5128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
26 changes: 23 additions & 3 deletions sbt-dotty/src/dotty/tools/sbtplugin/DottyIDEPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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,

Expand Down
23 changes: 22 additions & 1 deletion sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
)
}

Expand Down