-
Notifications
You must be signed in to change notification settings - Fork 202
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
Add buildTargets/jvmEnvironment endpoint #1214
Conversation
@@ -863,6 +864,13 @@ final class BloopBspServices( | |||
private def toBuildTargetId(project: Project): bsp.BuildTargetIdentifier = | |||
bsp.BuildTargetIdentifier(project.bspUri) | |||
|
|||
private def toJvmBuildTarget(project: Project): bsp.JvmBuildTarget = { | |||
val javaHome = sys.props.get("java.home").map(s => bsp.Uri(Paths.get(s).toUri)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: sys.props
allocates a new immutable map containing all system properties on every method call so I personally use Option(System.getProperty(..))
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 We can merge this once the BSP PR is released
@@ -863,6 +864,13 @@ final class BloopBspServices( | |||
private def toBuildTargetId(project: Project): bsp.BuildTargetIdentifier = | |||
bsp.BuildTargetIdentifier(project.bspUri) | |||
|
|||
private def toJvmBuildTarget(project: Project): bsp.JvmBuildTarget = { | |||
val javaHome = Option(System.getProperty("java.home")).map(s => bsp.Uri(Paths.get(s).toUri)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just learned from an offline discussion with @jvican that Bloop supports configuring custom Java home per-project. See .platform
here
platform: Platform, |
We should use JdkConfig.javaHome
instead of the java.home
system property.
build.sbt
Outdated
@@ -27,6 +27,7 @@ val benchmarkBridge = project | |||
lazy val bloopShared = (project in file("shared")) | |||
.settings( | |||
name := "bloop-shared", | |||
resolvers += Resolver.sonatypeRepo("snapshots"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should cut a new stable BSP release so we don't use SNAPSHOTs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @lukaszwawrzyk thanks for your work, overall LGTM 👍 I've just left some comments and suggestions.
@@ -863,6 +864,20 @@ final class BloopBspServices( | |||
private def toBuildTargetId(project: Project): bsp.BuildTargetIdentifier = | |||
bsp.BuildTargetIdentifier(project.bspUri) | |||
|
|||
private def toJvmBuildTarget(project: Project): bsp.JvmBuildTarget = { | |||
Option(project.platform) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have some of this logic already in a method called project.jdkConfig
. What do you think about using that instead of this? We can also replace the values of java.home
and the java version and use those that are available in JavaRuntime
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I guess it is enough to use project.jdkConfig, anyway it sets the correct jvm default config if not provided, and if it returns none, JvmBuildTarget can be empty as it means native or js.
val javaHome = Option(System.getProperty("java.home")).map(s => bsp.Uri(Paths.get(s).toUri)) | ||
val javaVersion = Option(System.getProperty("java.vm.specification.version")) | ||
bsp.JvmBuildTarget(javaHome, javaVersion) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this method returning a jvm build target always, regardless of the platform?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why return a JvmBuildTarget
here for projects that are not JVM?
} | ||
.getOrElse { | ||
val javaHome = Option(System.getProperty("java.home")).map(s => bsp.Uri(Paths.get(s).toUri)) | ||
val javaVersion = Option(System.getProperty("java.vm.specification.version")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you really use you want java.vm.specification.version
here instead of java.version
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened to the use of java.specification.vm.version
?
val javaHome = Option(System.getProperty("java.home")).map(s => bsp.Uri(Paths.get(s).toUri)) | ||
val javaVersion = Option(System.getProperty("java.vm.specification.version")) | ||
bsp.JvmBuildTarget(javaHome, javaVersion) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why return a JvmBuildTarget
here for projects that are not JVM?
@@ -863,6 +864,17 @@ final class BloopBspServices( | |||
private def toBuildTargetId(project: Project): bsp.BuildTargetIdentifier = | |||
bsp.BuildTargetIdentifier(project.bspUri) | |||
|
|||
private def toJvmBuildTarget(project: Project): bsp.JvmBuildTarget = { | |||
project.jdkConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: could we make all of this as concise as possible by using pattern matching here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
So I addressed the comment about not filling in JvmBuildTarget in case when target is not jvm. |
@lukaszwawrzyk Great, thanks for the changes!
Why do we return @olafurpg Any thoughts? |
Good catch! The |
We will need to do the same change for bsp4j, this field is optional. |
ab49ffe
to
3c0f7f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI is green now with the updated bsp4s dependency 👍
@@ -2,6 +2,7 @@ package bloop.bsp | |||
|
|||
import java.io.InputStream | |||
import java.net.URI | |||
import java.nio.file.Paths |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused import
Spoke with @olafurpg offline and we agreed on merging this so that we don't need to wait for another review cycle to merge this 😄 We'll remove the unused import whenever we set up scalafix automatically in the bloop build. |
Depends on build-server-protocol/build-server-protocol#113
Just implements the new endpoint, to currently be exactly the same as jvmTestEnvironment.
Fills in new optional parameters javaHome and javaVersion, currently based on the jvm that bloop is running on. In future we may allow to customize it through Config.Project