Skip to content

Commit

Permalink
Merge pull request #2083 from tgodzik/update-bsp
Browse files Browse the repository at this point in the history
improvement: Add main classes to JvmEnvironmentItem
  • Loading branch information
ckipp01 committed Jun 26, 2023
2 parents 54d76cf + 667ef2d commit 75d7329
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion frontend/src/main/scala/bloop/bsp/BloopBspServices.scala
Original file line number Diff line number Diff line change
Expand Up @@ -782,13 +782,15 @@ final class BloopBspServices(
environmentVariables = state.commonOptions.env.toMap
workingDirectory = project.workingDirectory.toString
javaOptions <- project.runtimeJdkConfig.map(_.javaOptions.toList)
classNames = Tasks.findMainClasses(state, project)
} yield {
bsp.JvmEnvironmentItem(
id,
fullClasspath.toList,
javaOptions,
workingDirectory,
environmentVariables
environmentVariables,
Some(classNames.map(bsp.JvmMainClass(_, Nil)))
)
}).toList
Task.now((state, Right(environmentEntries)))
Expand Down
13 changes: 9 additions & 4 deletions frontend/src/test/scala/bloop/bsp/BspProtocolSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ class BspProtocolSpec(
object Sources {
val `A.scala` =
"""/A.scala
|object A
|object A {
| def main(args: Array[String]): Unit = ???
|}
""".stripMargin
}

Expand All @@ -129,6 +131,7 @@ class BspProtocolSpec(
val jvmConfig = Some(Config.JvmConfig(None, jvmOptions))
val runtimeJvmOptions = List("-DOTHER_OPTION=Y") ++ workingDirectoryOption
val runtimeJvmConfig = Some(Config.JvmConfig(None, runtimeJvmOptions))
val runtimeMainClasses = Some(List(bsp.JvmMainClass("A", Nil)))
val `A` = TestProject(
workspace,
"a",
Expand All @@ -140,8 +143,9 @@ class BspProtocolSpec(
val projects = List(`A`)

loadBspState(workspace, projects, logger) { state =>
val compileState = state.compile(`A`)
val (stateA: ManagedBspTestState, environmentItems: List[JvmEnvironmentItem]) =
extractor(state, `A`)
extractor(compileState, `A`)
assert(environmentItems.size == 1)
assert(stateA.status == ExitStatus.Ok)

Expand All @@ -164,10 +168,11 @@ class BspProtocolSpec(
)

assert(environmentItem.jvmOptions == runtimeJvmOptions)
assert(environmentItem.mainClasses == runtimeMainClasses)
}
}

test("check the correct contents of jvm test environment") {
test("check-jvm-test-environment") {
TestUtil.withinWorkspace { workspace =>
testEnvironmentFetching(
workspace,
Expand All @@ -180,7 +185,7 @@ class BspProtocolSpec(
}
}

test("check the correct contents of jvm run environment") {
test("check-jvm-main-environment") {
TestUtil.withinWorkspace { workspace =>
testEnvironmentFetching(
workspace,
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object Dependencies {
// Keep in sync in BloopComponentCompiler
val zincVersion = "1.8.1"

val bspVersion = "2.1.0-M3"
val bspVersion = "2.1.0-M5"

val scalazVersion = "7.3.7"
val lmVersion = "1.9.0"
Expand Down

0 comments on commit 75d7329

Please sign in to comment.