Skip to content

Commit 7f89bfa

Browse files
committed
Merge prepareIDE with configureIDE
In the next commit we'll extend configureIDE to work even when it needs to update some settings to set the scalaVersion to Dotty. Since this update takes some time and is discarded at the end of the task, it makes sense to run the configuration and compilation steps in the same task to avoid having to do the settings update twice.
1 parent fa9f8b2 commit 7f89bfa

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

project/Build.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ object Build {
9494
// Override `launchIDE` from sbt-dotty to use the language-server and
9595
// vscode extension from the source repository of dotty instead of a
9696
// published version.
97-
launchIDE := (run in `dotty-language-server`).dependsOn(prepareIDE).toTask("").value
97+
launchIDE := (run in `dotty-language-server`).dependsOn(configureIDE).toTask("").value
9898
)
9999

100100
// Only available in vscode-dotty
@@ -882,7 +882,7 @@ object Build {
882882

883883

884884
sbtPlugin := true,
885-
version := "0.1.1",
885+
version := "0.1.2-SNAPSHOT",
886886
ScriptedPlugin.scriptedSettings,
887887
ScriptedPlugin.sbtTestDirectory := baseDirectory.value / "sbt-test",
888888
ScriptedPlugin.scriptedBufferLog := false,

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ object DottyIDEPlugin extends AutoPlugin {
4444
}
4545

4646
private val projectConfig = taskKey[Option[ProjectConfig]]("")
47-
private val configureIDE = taskKey[Unit]("Generate IDE config files")
4847
private val compileForIDE = taskKey[Unit]("Compile all projects supported by the IDE")
4948
private val runCode = taskKey[Unit]("")
5049

5150
object autoImport {
52-
val prepareIDE = taskKey[Unit]("Prepare for IDE launch")
51+
val configureIDE = taskKey[Unit]("Generate IDE config files")
5352
val launchIDE = taskKey[Unit]("Run Visual Studio Code on this project")
5453
}
5554

@@ -64,6 +63,11 @@ object DottyIDEPlugin extends AutoPlugin {
6463
Def.derive(projectConfig := {
6564
if (sources.value.isEmpty) None
6665
else {
66+
// Not needed to generate the config, but this guarantees that the
67+
// generated config is usable by an IDE without any extra compilation
68+
// step.
69+
val _ = compile.value
70+
6771
val id = s"${thisProject.value.id}/${configuration.value.name}"
6872
val compilerVersion = scalaVersion.value
6973
.replace("-nonbootstrapped", "") // The language server is only published bootstrapped
@@ -135,11 +139,6 @@ object DottyIDEPlugin extends AutoPlugin {
135139
.start()
136140
},
137141

138-
prepareIDE := {
139-
val x1 = configureIDE.value
140-
val x2 = compileForIDE.value
141-
},
142-
143-
launchIDE := runCode.dependsOn(prepareIDE).value
142+
launchIDE := runCode.dependsOn(configureIDE).value
144143
)
145144
}

0 commit comments

Comments
 (0)