From e53cb5bfa6d361124ab5b60f41efdd8708253ff6 Mon Sep 17 00:00:00 2001 From: tgodzik Date: Thu, 10 Oct 2024 18:19:03 +0200 Subject: [PATCH 1/3] improvement: Remove workaround for Bloop and update docs --- .../_docs/contributing/setting-up-your-ide.md | 24 +++++++------- project/Build.scala | 4 +-- project/NoBloopExport.scala | 31 ------------------- 3 files changed, 14 insertions(+), 45 deletions(-) delete mode 100644 project/NoBloopExport.scala diff --git a/docs/_docs/contributing/setting-up-your-ide.md b/docs/_docs/contributing/setting-up-your-ide.md index a02c1dee63cb..a15bf651ef74 100644 --- a/docs/_docs/contributing/setting-up-your-ide.md +++ b/docs/_docs/contributing/setting-up-your-ide.md @@ -3,16 +3,15 @@ layout: doc-page title: Setting up your IDE --- -You can use either Metals with your favorite editor (VS Code, Neovim, Sublime) -or [IntelliJ IDEA for -Scala](https://www.jetbrains.com/help/idea/discover-intellij-idea-for-scala.html) +You can use either Metals with your favorite editor or +[IntelliJ IDEA for Scala](https://www.jetbrains.com/help/idea/discover-intellij-idea-for-scala.html) to work on the Scala 3 codebase. There are however a few additional considerations to take into account. ## Bootstrapping Projects -The sbt build for dotty implements bootstrapping within the same build, so each component has -two projects: +The sbt build for dotty implements bootstrapping within the same build, so each +component has two projects: ``` sbt:scala3> projects @@ -33,9 +32,9 @@ you'll actually want these modules exported. In order to achieve this you'll want to make sure you do two things: 1. You'll want to find and change the following under - `commonBootstrappedSettings` which is found in the - [`Build.scala`](https://github.com/scala/scala3/blob/main/project/Build.scala) - file. + `commonBootstrappedSettings` which is found in the + [`Build.scala`](https://github.com/scala/scala3/blob/main/project/Build.scala) + file. ```diff @@ -43,12 +42,13 @@ want to make sure you do two things: + bspEnabled := true, ``` -2. Set `sbt` as your build server instead of the default, Bloop. You can achieve - this with the `Metals: Switch Build Server` command and then choosing sbt. In - VSCode, this looks like this: +2. Run `sbt publishLocal` to get the needed presentation compiler jars. -![bsp-switch](https://user-images.githubusercontent.com/777748/241986423-0724ae74-0ebd-42ef-a1b7-4d17678992b4.png) +By default Metals uses Bloop build server, however you can also use sbt +directly. You can achieve this with the `Metals: Switch Build Server` command +and then choosing sbt. In VSCode, this looks like this: +![bsp-switch](https://user-images.githubusercontent.com/777748/241986423-0724ae74-0ebd-42ef-a1b7-4d17678992b4.png) ### IntelliJ diff --git a/project/Build.scala b/project/Build.scala index 84ce00d11577..6ec933a599b3 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -469,8 +469,8 @@ object Build { } // Settings used when compiling dotty with a non-bootstrapped dotty - lazy val commonBootstrappedSettings = commonDottySettings ++ NoBloopExport.settings ++ Seq( - // To enable support of scaladoc and language-server projects you need to change this to true and use sbt as your build server + lazy val commonBootstrappedSettings = commonDottySettings ++ Seq( + // To enable support of scaladoc and language-server projects you need to change this to true bspEnabled := false, (Compile / unmanagedSourceDirectories) += baseDirectory.value / "src-bootstrapped", diff --git a/project/NoBloopExport.scala b/project/NoBloopExport.scala deleted file mode 100644 index 7a088a405781..000000000000 --- a/project/NoBloopExport.scala +++ /dev/null @@ -1,31 +0,0 @@ -import sbt._ -import Keys._ - -/* With <3 from scala-js */ -object NoBloopExport { - private lazy val bloopGenerateKey: Option[TaskKey[Result[Option[File]]]] = { - val optBloopKeysClass: Option[Class[_]] = try { - Some(Class.forName("bloop.integrations.sbt.BloopKeys")) - } catch { - case _: ClassNotFoundException => None - } - - optBloopKeysClass.map { bloopKeysClass => - val bloopGenerateGetter = bloopKeysClass.getMethod("bloopGenerate") - bloopGenerateGetter.invoke(null).asInstanceOf[TaskKey[Result[Option[File]]]] - } - } - - /** Settings to prevent the project from being exported to IDEs. */ - lazy val settings: Seq[Setting[_]] = { - bloopGenerateKey match { - case None => - Nil - case Some(key) => - Seq( - Compile / key := Value(None), - Test / key := Value(None), - ) - } - } -} From 7aebb9dab2e557aff2b3276ecd6ad5e31bf357e3 Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Thu, 31 Oct 2024 13:11:38 +0100 Subject: [PATCH 2/3] improvement: Disable projects not compiling with Bloop --- docs/_docs/contributing/setting-up-your-ide.md | 6 +++--- project/Build.scala | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/_docs/contributing/setting-up-your-ide.md b/docs/_docs/contributing/setting-up-your-ide.md index a15bf651ef74..3779ce1c3403 100644 --- a/docs/_docs/contributing/setting-up-your-ide.md +++ b/docs/_docs/contributing/setting-up-your-ide.md @@ -31,15 +31,15 @@ Normally this is fine, but if you're working on certain modules like `scaladoc` you'll actually want these modules exported. In order to achieve this you'll want to make sure you do two things: -1. You'll want to find and change the following under +1. You'll want to find and change the following above `commonBootstrappedSettings` which is found in the [`Build.scala`](https://github.com/scala/scala3/blob/main/project/Build.scala) file. ```diff -- bspEnabled := false, -+ bspEnabled := true, +- val enableBspAllProjects = false, ++ val enableBspAllProjects = true, ``` 2. Run `sbt publishLocal` to get the needed presentation compiler jars. diff --git a/project/Build.scala b/project/Build.scala index 6ec933a599b3..d955f7067626 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -468,10 +468,20 @@ object Build { ) ++ extMap } + /* This projects are irrelevant from IDE point of view and do not compile with Bloop*/ + val fullyDisabledProjects = Set( + "scala2-library-cc", + "scala2-library-bootstrapped", + "scala2-library-cc-tasty", + "scala2-library-tasty" + ) + + val enableBspAllProjects = false + // Settings used when compiling dotty with a non-bootstrapped dotty lazy val commonBootstrappedSettings = commonDottySettings ++ Seq( // To enable support of scaladoc and language-server projects you need to change this to true - bspEnabled := false, + bspEnabled := { if(fullyDisabledProjects(name.value)) false else enableBspAllProjects }, (Compile / unmanagedSourceDirectories) += baseDirectory.value / "src-bootstrapped", version := dottyVersion, From c450073b308364217a203cf8bd2c7c09212da475 Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Thu, 31 Oct 2024 15:26:51 +0100 Subject: [PATCH 3/3] Fix typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sébastien Doeraene --- project/Build.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Build.scala b/project/Build.scala index d955f7067626..5b357dab6ef6 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -468,7 +468,7 @@ object Build { ) ++ extMap } - /* This projects are irrelevant from IDE point of view and do not compile with Bloop*/ + /* These projects are irrelevant from IDE point of view and do not compile with Bloop*/ val fullyDisabledProjects = Set( "scala2-library-cc", "scala2-library-bootstrapped",