@@ -15,6 +15,16 @@ import scala.collection.mutable.ListBuffer
1515import DottyPlugin .autoImport ._
1616
1717object 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+
1828 // Adapted from scala-reflect
1929 private def distinctBy [A , B ](xs : Seq [A ])(f : A => B ): Seq [A ] = {
2030 val buf = new mutable.ListBuffer [A ]
@@ -111,14 +121,20 @@ object DottyIDEPlugin extends AutoPlugin {
111121 }
112122 }
113123
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 ] = {
116127 val structure = Project .structure(state)
117128 val settings = structure.data
118129 val joinedTask = projRefs.flatMap { projRef =>
119130 val project = Project .getProjectForReference(projRef, structure).get
120131 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+ }
122138 }
123139 }.join
124140
@@ -151,20 +167,12 @@ object DottyIDEPlugin extends AutoPlugin {
151167
152168 private val projectConfig = taskKey[Option [ProjectConfig ]](" " )
153169
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-
162170 override def requires : Plugins = plugins.JvmPlugin
163171 override def trigger = allRequirements
164172
165173 def configureIDE = Command .command(" configureIDE" ) { origState =>
166174 val (dottyVersion, projRefs, dottyState) = dottySetup(origState)
167- val configs0 = runInAllConfigurations (projectConfig, projRefs, dottyState).flatten
175+ val configs0 = runInAllIDEConfigurations (projectConfig, projRefs, dottyState).flatten
168176
169177 // Drop configurations that do not define their own sources, but just
170178 // inherit their sources from some other configuration.
@@ -192,7 +200,7 @@ object DottyIDEPlugin extends AutoPlugin {
192200
193201 def compileForIDE = Command .command(" compileForIDE" ) { origState =>
194202 val (dottyVersion, projRefs, dottyState) = dottySetup(origState)
195- runInAllConfigurations (compile, projRefs, dottyState)
203+ runInAllIDEConfigurations (compile, projRefs, dottyState)
196204
197205 origState
198206 }
@@ -234,6 +242,8 @@ object DottyIDEPlugin extends AutoPlugin {
234242 override def buildSettings : Seq [Setting [_]] = Seq (
235243 commands ++= Seq (configureIDE, compileForIDE),
236244
245+ excludeFromIDE := false ,
246+
237247 codeCommand := {
238248 Seq (" code" , " -n" )
239249 },
0 commit comments