Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement: Add main classes to JvmEnvironmentItem #2083

Merged
merged 2 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -17,7 +17,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.8.0"
Expand Down