@@ -378,8 +378,17 @@ def setForkedWorkingDirectory: Seq[Setting[_]] = {
378
378
setting ++ inTask(run)(setting)
379
379
}
380
380
381
+ lazy val skipProjectInIDEs : Seq [Setting [_]] = Seq (
382
+ // The current project is not considered a bsp project.
383
+ // BSP clients will not see the current project and will not offer any IDE support.
384
+ bspEnabled := false ,
385
+ // Additionally, the current project should not be imported in IntelliJ IDEA.
386
+ // The setting is defined in https://github.com/JetBrains/sbt-ide-settings?tab=readme-ov-file#using-the-settings-without-plugin
387
+ SettingKey [Boolean ](" ide-skip-project" ).withRank(KeyRanks .Invisible ) := ! bspEnabled.value
388
+ )
389
+
381
390
// This project provides the STARR scalaInstance for bootstrapping
382
- lazy val bootstrap = project in file(" target/bootstrap" )
391
+ lazy val bootstrap = project.in( file(" target/bootstrap" )).settings(skipProjectInIDEs )
383
392
384
393
lazy val library = configureAsSubproject(project)
385
394
.settings(generatePropertiesFileSettings)
@@ -696,6 +705,7 @@ lazy val specLib = project.in(file("test") / "instrumented")
696
705
)
697
706
}.taskValue
698
707
)
708
+ .settings(skipProjectInIDEs)
699
709
700
710
lazy val bench = project.in(file(" test" ) / " benchmarks" )
701
711
.dependsOn(library, compiler)
@@ -709,6 +719,11 @@ lazy val bench = project.in(file("test") / "benchmarks")
709
719
compileOrder := CompileOrder .JavaThenScala , // to allow inlining from Java ("... is defined in a Java source (mixed compilation), no bytecode is available")
710
720
scalacOptions ++= Seq (" -feature" , " -opt:l:inline" , " -opt-inline-from:scala/**" , " -opt-warnings" ),
711
721
).settings(inConfig(JmhPlugin .JmhKeys .Jmh )(scalabuild.JitWatchFilePlugin .jitwatchSettings))
722
+ .settings(
723
+ // Skips JMH source generators during IDE import to avoid needing to compile scala-library during the import
724
+ // should not be needed once sbt-jmh 0.4.3 is out (https://github.com/sbt/sbt-jmh/pull/207)
725
+ inConfig(Jmh )(skipProjectInIDEs)
726
+ )
712
727
713
728
// Jigsaw: reflective access between modules (`setAccessible(true)`) requires an `opens` directive.
714
729
// This is enforced by error (not just by warning) since JDK 16. In our tests we use reflective access
@@ -811,6 +826,7 @@ def osgiTestProject(p: Project, framework: ModuleID) = p
811
826
},
812
827
cleanFiles += (ThisBuild / buildDirectory).value / " osgi"
813
828
)
829
+ .settings(skipProjectInIDEs)
814
830
815
831
lazy val partestJavaAgent = Project (" partest-javaagent" , file(" ." ) / " src" / " partest-javaagent" )
816
832
.settings(commonSettings)
@@ -908,6 +924,7 @@ lazy val libraryAll = Project("library-all", file(".") / "target" / "library-all
908
924
" /project/description" -> <description >The Scala Standard Library and Official Modules </description >
909
925
)
910
926
)
927
+ .settings(skipProjectInIDEs)
911
928
.dependsOn(library, reflect)
912
929
913
930
lazy val scalaDist = Project (" scala-dist" , file(" ." ) / " target" / " scala-dist-dist-src-dummy" )
@@ -954,6 +971,7 @@ lazy val scalaDist = Project("scala-dist", file(".") / "target" / "scala-dist-di
954
971
),
955
972
(Compile / packageSrc / publishArtifact) := false
956
973
)
974
+ .settings(skipProjectInIDEs)
957
975
.dependsOn(libraryAll, compiler, scalap)
958
976
959
977
lazy val scala2 : Project = (project in file(" ." ))
@@ -1100,6 +1118,7 @@ lazy val dist = (project in file("dist"))
1100
1118
.dependsOn(distDependencies.map((_ / Runtime / packageBin/ packagedArtifact)): _* )
1101
1119
.value
1102
1120
)
1121
+ .settings(skipProjectInIDEs)
1103
1122
.dependsOn(distDependencies.map(p => p : ClasspathDep [ProjectReference ]): _* )
1104
1123
1105
1124
/**
0 commit comments