Skip to content

Commit

Permalink
Remove the possibility to read proeprties from.jvmopts
Browse files Browse the repository at this point in the history
This is no longer a supported method of specifying the server properties. Users should instead us `$HOME/.bloop/bloop.json`
  • Loading branch information
tgodzik committed Mar 28, 2022
1 parent 3cdfa19 commit 2584f32
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions bloopgun/src/main/scala/bloop/bloopgun/util/Environment.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,39 +50,34 @@ object Environment {

/**
* Reads all jvm options required to start the Bloop server, in order of priority:
*
*
* Parses `-J` prefixed jvm options in the arguments passed to the server command.
*
* Prior to 1.5.0 it used to also:
* 1. Read `$$HOME/.bloop/.jvmopts` file.
* 2. Read `.jvmopts` file right next to the location of the bloop server jar.
* 3. Parse `-J` prefixed jvm options in the arguments passed to the server command.
*
* Now, it only logs a warning if the file detected.
*
* Returns a list of jvm options with no `-J` prefix.
*/
def detectJvmOptionsForServer(
server: LocatedServer,
serverArgs: List[String],
logger: Logger
): List[String] = {
def readJvmOptsFile(jvmOptsFile: Path): List[String] = {
if (!Files.isReadable(jvmOptsFile)) {
def detectJvmOptsFile(jvmOptsFile: Path): Unit = {
if (Files.exists(jvmOptsFile)) {
logger.error(s"Ignored unreadable ${jvmOptsFile.toAbsolutePath()}")
}

Nil
} else {
val contents = new String(Files.readAllBytes(jvmOptsFile), StandardCharsets.UTF_8)
contents.linesIterator.toList
logger.warn(s"Since Bloop 1.5.0 ${jvmOptsFile.toAbsolutePath()} is ignored.")
}
}

val jvmServerArgs = serverArgs.filter(_.startsWith("-J"))
val jvmOptionsFromHome = readJvmOptsFile(Environment.defaultBloopDirectory.resolve(".jvmopts"))
val jvmOptionsFromPathNextToBinary = server match {
case AvailableAtPath(binary) => readJvmOptsFile(binary.getParent.resolve(".jvmopts"))
detectJvmOptsFile(Environment.defaultBloopDirectory.resolve(".jvmopts"))
server match {
case AvailableAtPath(binary) => detectJvmOptsFile(binary.getParent.resolve(".jvmopts"))
case _ => Nil
}

(jvmOptionsFromHome ++ jvmOptionsFromPathNextToBinary ++ jvmServerArgs).map(_.stripPrefix("-J"))
jvmServerArgs.map(_.stripPrefix("-J"))
}

// TODO: Add more options to better tweak GC based on benchmarks
Expand Down

0 comments on commit 2584f32

Please sign in to comment.