Skip to content

Conversation

adpi2
Copy link
Member

@adpi2 adpi2 commented Jul 12, 2021

In order to start the sbt server we must use the sbt script because it is the only way to load the .sbtopts and the .jvmopts files properly.

To do so the sbt script can pass a -Dsbt.script option to the Java process:

  • If the Java process is an sbt client: the value of -Dsbt.script is used to start the server
  • If the Java process is an sbt server: the value of -Dsbt.script is written into the .bsp/sbt.json file

Example of bsp/sbt.json file:

{
  "name":"sbt",
  "version":"1.5.5-SNAPSHOT",
  "bspVersion":"2.0.0-M5",
  "languages":["scala"],
  "argv":[
    "/home/.sdkman/candidates/sbt/current/bin/sbt",
    "-bsp",
    "-Dsbt.script=/home/.sdkman/candidates/sbt/current/bin/sbt"
  ]
}

This PR fixes #6575 and #6476, and part of #6468.
This PR makes #6580 not necessary (except if IntelliJ starts sbt using the sbt-launch.jar directly).

In order to start the sbt server we must use the sbt script because
it is the only way to load the .sbtopts and the .jvmopts file properly.

To do so the sbt script can pass a -Dsbt.script prop to the java server.
It is used in the NetworkClient to start the server, and it is replicated
in the BuildServerConnection file (.bsp/sbt.json).
eed3si9n
eed3si9n previously approved these changes Jul 12, 2021
Copy link
Contributor

@bjaglin bjaglin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, I successfully tested it on my laptop for our enteprise use case: we want BSP clients to honor the -Dsbt.repository.config / -Dsbt.override.build.repos flags from .sbtopts to get a safe, deterministic build.

bjaglin
bjaglin previously approved these changes Jul 14, 2021
Copy link
Contributor

@bjaglin bjaglin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.sbtopts doesn't get picked up when sbt server gets started by Metals
3 participants