@@ -15,6 +15,16 @@ import scala.collection.mutable.ListBuffer
15
15
import DottyPlugin .autoImport ._
16
16
17
17
object DottyIDEPlugin extends AutoPlugin {
18
+ object autoImport {
19
+ val excludeFromIDE = settingKey[Boolean ](" If true, do not import this project or configuration in the Dotty IDE" )
20
+
21
+ val codeCommand = taskKey[Seq [String ]](" Command to start VSCode" )
22
+ val runCode = taskKey[Unit ](" Start VSCode, usually called from launchIDE" )
23
+ val launchIDE = taskKey[Unit ](" Configure and run VSCode on this project" )
24
+ }
25
+
26
+ import autoImport ._
27
+
18
28
// Adapted from scala-reflect
19
29
private def distinctBy [A , B ](xs : Seq [A ])(f : A => B ): Seq [A ] = {
20
30
val buf = new mutable.ListBuffer [A ]
@@ -111,14 +121,20 @@ object DottyIDEPlugin extends AutoPlugin {
111
121
}
112
122
}
113
123
114
- /** Run task `key` in all configurations in all projects in `projRefs`, using state `state` */
115
- private def runInAllConfigurations [T ](key : TaskKey [T ], projRefs : Seq [ProjectRef ], state : State ): Seq [T ] = {
124
+ /** Run task `key` in all configurations in all projects in `projRefs`, using state `state`,
125
+ * configurations where `excludeFromIDE` is `true` are skipped. */
126
+ private def runInAllIDEConfigurations [T ](key : TaskKey [T ], projRefs : Seq [ProjectRef ], state : State ): Seq [T ] = {
116
127
val structure = Project .structure(state)
117
128
val settings = structure.data
118
129
val joinedTask = projRefs.flatMap { projRef =>
119
130
val project = Project .getProjectForReference(projRef, structure).get
120
131
project.configurations.flatMap { config =>
121
- key.in(projRef, config).get(settings)
132
+ excludeFromIDE.in(projRef, config).get(settings) match {
133
+ case Some (true ) =>
134
+ None // skip this configuration
135
+ case _ =>
136
+ key.in(projRef, config).get(settings)
137
+ }
122
138
}
123
139
}.join
124
140
@@ -151,20 +167,12 @@ object DottyIDEPlugin extends AutoPlugin {
151
167
152
168
private val projectConfig = taskKey[Option [ProjectConfig ]](" " )
153
169
154
- object autoImport {
155
- val codeCommand = taskKey[Seq [String ]](" Command to start VSCode" )
156
- val runCode = taskKey[Unit ](" Start VSCode, usually called from launchIDE" )
157
- val launchIDE = taskKey[Unit ](" Configure and run VSCode on this project" )
158
- }
159
-
160
- import autoImport ._
161
-
162
170
override def requires : Plugins = plugins.JvmPlugin
163
171
override def trigger = allRequirements
164
172
165
173
def configureIDE = Command .command(" configureIDE" ) { origState =>
166
174
val (dottyVersion, projRefs, dottyState) = dottySetup(origState)
167
- val configs0 = runInAllConfigurations (projectConfig, projRefs, dottyState).flatten
175
+ val configs0 = runInAllIDEConfigurations (projectConfig, projRefs, dottyState).flatten
168
176
169
177
// Drop configurations that do not define their own sources, but just
170
178
// inherit their sources from some other configuration.
@@ -192,7 +200,7 @@ object DottyIDEPlugin extends AutoPlugin {
192
200
193
201
def compileForIDE = Command .command(" compileForIDE" ) { origState =>
194
202
val (dottyVersion, projRefs, dottyState) = dottySetup(origState)
195
- runInAllConfigurations (compile, projRefs, dottyState)
203
+ runInAllIDEConfigurations (compile, projRefs, dottyState)
196
204
197
205
origState
198
206
}
@@ -234,6 +242,8 @@ object DottyIDEPlugin extends AutoPlugin {
234
242
override def buildSettings : Seq [Setting [_]] = Seq (
235
243
commands ++= Seq (configureIDE, compileForIDE),
236
244
245
+ excludeFromIDE := false ,
246
+
237
247
codeCommand := {
238
248
Seq (" code" , " -n" )
239
249
},
0 commit comments