Skip to content

Commit

Permalink
bugfix: Take into account JVM_OPTS and SBT_OPTS env variables
Browse files Browse the repository at this point in the history
Previously, they seemed to be ignored. Now, we fallback if the file doesn't exist.
  • Loading branch information
tgodzik committed Oct 25, 2023
1 parent dabe36c commit 13e8ed1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ case class SbtBuildTool(
List(
javaArgs,
sbtVersion,
SbtOpts.fromWorkspace(workspace),
JvmOpts.fromWorkspace(workspace),
SbtOpts.fromWorkspaceOrEnv(workspace),
JvmOpts.fromWorkspaceOrEnv(workspace),
jarArgs,
sbtArgs,
).flatten
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import scala.meta.io.AbsolutePath
*/
object JvmOpts {

def fromWorkspace(workspace: AbsolutePath): List[String] = {
def fromWorkspaceOrEnv(workspace: AbsolutePath): List[String] = {
val jvmOpts = workspace.resolve(".jvmopts")
if (jvmOpts.isFile && Files.isReadable(jvmOpts.toNIO)) {
val text = FileIO.slurp(jvmOpts, StandardCharsets.UTF_8)
text.linesIterator.map(_.trim).filter(_.startsWith("-")).toList
} else {
Nil
fromEnvironment
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import scala.meta.io.AbsolutePath
*/
object SbtOpts {

def fromWorkspace(workspace: AbsolutePath): List[String] = {
def fromWorkspaceOrEnv(workspace: AbsolutePath): List[String] = {
val sbtOpts = workspace.resolve(".sbtopts")
if (sbtOpts.isFile && Files.isReadable(sbtOpts.toNIO)) {
val text = FileIO.slurp(sbtOpts, StandardCharsets.UTF_8)
process(text.linesIterator.map(_.trim).toList)
} else {
Nil
fromEnvironment
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/src/test/scala/tests/SbtOptsSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class SbtOptsSuite extends BaseSuite {
test(name) {
val root = FileLayout.fromString(original)
val obtained =
SbtOpts.fromWorkspace(root).mkString("\n") ++
JvmOpts.fromWorkspace(root).mkString("\n")
SbtOpts.fromWorkspaceOrEnv(root).mkString("\n") ++
JvmOpts.fromWorkspaceOrEnv(root).mkString("\n")
assertNoDiff(obtained, expected)
}
}
Expand Down

0 comments on commit 13e8ed1

Please sign in to comment.