Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aad0070

Browse files
committed
Backport: disable bsp / IntelliJ for non-code sbt projects
Backports #11097
1 parent 1e47d0d commit aad0070

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

build.sbt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,17 @@ def setForkedWorkingDirectory: Seq[Setting[_]] = {
378378
setting ++ inTask(run)(setting)
379379
}
380380

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+
381390
// 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)
383392

384393
lazy val library = configureAsSubproject(project)
385394
.settings(generatePropertiesFileSettings)
@@ -696,6 +705,7 @@ lazy val specLib = project.in(file("test") / "instrumented")
696705
)
697706
}.taskValue
698707
)
708+
.settings(skipProjectInIDEs)
699709

700710
lazy val bench = project.in(file("test") / "benchmarks")
701711
.dependsOn(library, compiler)
@@ -709,6 +719,11 @@ lazy val bench = project.in(file("test") / "benchmarks")
709719
compileOrder := CompileOrder.JavaThenScala, // to allow inlining from Java ("... is defined in a Java source (mixed compilation), no bytecode is available")
710720
scalacOptions ++= Seq("-feature", "-opt:l:inline", "-opt-inline-from:scala/**", "-opt-warnings"),
711721
).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+
)
712727

713728
// Jigsaw: reflective access between modules (`setAccessible(true)`) requires an `opens` directive.
714729
// 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
811826
},
812827
cleanFiles += (ThisBuild / buildDirectory).value / "osgi"
813828
)
829+
.settings(skipProjectInIDEs)
814830

815831
lazy val partestJavaAgent = Project("partest-javaagent", file(".") / "src" / "partest-javaagent")
816832
.settings(commonSettings)
@@ -908,6 +924,7 @@ lazy val libraryAll = Project("library-all", file(".") / "target" / "library-all
908924
"/project/description" -> <description>The Scala Standard Library and Official Modules</description>
909925
)
910926
)
927+
.settings(skipProjectInIDEs)
911928
.dependsOn(library, reflect)
912929

913930
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
954971
),
955972
(Compile / packageSrc / publishArtifact) := false
956973
)
974+
.settings(skipProjectInIDEs)
957975
.dependsOn(libraryAll, compiler, scalap)
958976

959977
lazy val scala2: Project = (project in file("."))
@@ -1100,6 +1118,7 @@ lazy val dist = (project in file("dist"))
11001118
.dependsOn(distDependencies.map((_ / Runtime / packageBin/ packagedArtifact)): _*)
11011119
.value
11021120
)
1121+
.settings(skipProjectInIDEs)
11031122
.dependsOn(distDependencies.map(p => p: ClasspathDep[ProjectReference]): _*)
11041123

11051124
/**

0 commit comments

Comments
 (0)