Skip to content

Commit 5f79f49

Browse files
committed
Add mechanism for picking the highest java version for bloop, add docs, add fixme
1 parent 64e7131 commit 5f79f49

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

modules/build/src/main/scala/scala/build/bsp/BspImpl.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -620,10 +620,10 @@ final class BspImpl(
620620
case Right(preBuildProject) =>
621621
// FIXME we might want to report overridden options or chose a better merge strategy
622622
val projectBuildOptions = preBuildProject.prebuildModules
623-
.map(_.mainScope.buildOptions)
624-
.reduce(_ orElse _)
623+
.flatMap(m => Seq(m.mainScope.buildOptions, m.testScope.buildOptions))
625624

626-
lazy val projectJavaHome = projectBuildOptions.javaHome().value
625+
lazy val projectJavaHome = projectBuildOptions.map(_.javaHome().value)
626+
.maxBy(_.version)
627627

628628
val finalBloopSession =
629629
if (
@@ -633,10 +633,8 @@ final class BspImpl(
633633
s"Bloop JVM version too low, current ${bloopSession.get().remoteServer.jvmVersion.get
634634
.value} expected ${projectJavaHome.version}, restarting server"
635635
)
636-
// RelodableOptions don't take into account buildOptions from sources
636+
// ReloadableOptions don't take into account buildOptions from sources, so we need to update the bloopRifleConfig
637637
val updatedReloadableOptions = reloadableOptions.copy(
638-
buildOptions =
639-
reloadableOptions.buildOptions orElse projectBuildOptions,
640638
bloopRifleConfig = reloadableOptions.bloopRifleConfig.copy(
641639
javaPath = projectJavaHome.javaCommand,
642640
minimumBloopJvm = projectJavaHome.version

modules/build/src/main/scala/scala/build/bsp/BspReloadableOptions.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import scala.build.Logger
66
import scala.build.options.BuildOptions
77

88
/** The options and configurations that may be picked up on a bsp workspace/reload request.
9+
* They don't take into account options from sources.
10+
* The only two exceptions are the initial options in BspImpl.run
11+
* and in options used to launch new bloop in BspImpl.reloadBsp, which have the [[bloopRifleConfig]] updated.
912
*
1013
* @param buildOptions
1114
* passed options for building sources

modules/cli/src/main/scala/scala/cli/commands/bsp/Bsp.scala

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,28 @@ object Bsp extends ScalaCommand[BspOptions] {
136136

137137
// TODO reported override option values
138138
// FIXME Only some options need to be unified for the whole project, like scala version, JVM
139-
val finalBuildOptions = inputsAndBuildOptions.map(_._2).reduceLeft(_ orElse _)
139+
val combinedBuildOptions = inputsAndBuildOptions.map(_._2).reduceLeft(_ orElse _)
140140
val inputs = inputsAndBuildOptions.map(_._1)
141141

142142
if (options.shared.logging.verbosity >= 3)
143-
pprint.err.log(finalBuildOptions)
143+
pprint.err.log(combinedBuildOptions)
144144

145-
/** values used for lauching the bsp, especially for launching a bloop server, they include
146-
* options extracted from sources
145+
// FIXME Why do we need shared options to be combined with combinedBuildOptions to pass BspTestsDefault.test workspace update after adding file to main scope ???
146+
/** values used for launching the bsp, especially for launching a bloop server, they include
147+
* options extracted from sources in the bloop rifle config and in buildOptions
147148
*/
148149
val initialBspOptions = {
149150
val sharedOptions = getSharedOptions()
150151
val launcherOptions = getLauncherOptions()
151152
val envs = getEnvsFromFile()
152153
val bspBuildOptions = buildOptions(sharedOptions, launcherOptions, envs)
154+
<<<<<<< HEAD
153155
.orElse(finalBuildOptions)
154156
refreshPowerMode(launcherOptions, sharedOptions, envs)
157+
=======
158+
.orElse(combinedBuildOptions)
159+
160+
>>>>>>> cf44243b7 (Add mechanism for picking the highest java version for bloop, add docs, add fixme)
155161
BspReloadableOptions(
156162
buildOptions = bspBuildOptions,
157163
bloopRifleConfig = sharedOptions.bloopRifleConfig(Some(bspBuildOptions))

0 commit comments

Comments
 (0)