Skip to content

Commit

Permalink
Pass java opts to scalac
Browse files Browse the repository at this point in the history
  • Loading branch information
MaciejG604 committed Dec 3, 2023
1 parent 9385014 commit e46ccfe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Expand Up @@ -98,6 +98,9 @@ final case class SimpleScalaCompiler(
javaHomeOpt.map(SimpleJavaCompiler.javaCommand(_)).getOrElse(defaultJavaCommand)

val javaOptions = defaultJavaOptions ++
scalacOptions
.filter(_.startsWith("-J"))
.map(_.stripPrefix("-J")) ++
javacOptions
.filter(_.startsWith("-J"))
.map(_.stripPrefix("-J"))
Expand Down
Expand Up @@ -744,4 +744,33 @@ abstract class CompileTestDefinitions(val scalaVersionOpt: Option[String])
expect(!secondOutput.contains("Compiled project"))
}
}

test("pass java options to scalac when server=false") {
val inputs = TestInputs(
os.rel / "Main.scala" ->
"""object Main extends App {
| println("Hello")
|}
|""".stripMargin
)
inputs.fromRoot { root =>
val res = os.proc(
TestUtil.cli,
"compile",
"--scalac-option=-J-XX:MaxHeapSize=1k",
"--server=false",
extraOptions,
"."
)
.call(cwd = root, check = false, mergeErrIntoOut = true)
expect(res.exitCode == 1)
assertNoDiff(
res.out.text(),
"""Error occurred during initialization of VM
|Too small maximum heap
|Compilation failed
|""".stripMargin
)
}
}
}

0 comments on commit e46ccfe

Please sign in to comment.