Skip to content

Commit 46481db

Browse files
committed
Add mechanism for picking the highest java version for bloop, add docs, add fixme
1 parent 12acd54 commit 46481db

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ object Bsp extends ScalaCommand[BspOptions] {
137137

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

143143
if (options.shared.logging.verbosity >= 3)
144-
pprint.err.log(finalBuildOptions)
144+
pprint.err.log(combinedBuildOptions)
145145

146146
/** values used for launching the bsp, especially for launching the bloop server, they do not
147147
* include options extracted from sources, except in bloopRifleConfig - it's needed for

0 commit comments

Comments
 (0)