Skip to content
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

Pass java opts to scalac #2601

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
)
}
}
}