dwijnand / scala-runners

Scala Runners: a Coursier-based alternative implementation
Apache License 2.0
43 stars 5 forks source link

Support JVM options with `-J` #14

Closed lrytz closed 4 years ago

lrytz commented 4 years ago

Also pass properties with -J -Dfoo=bar as recommended on https://get-coursier.io/docs/cli-launch.html#java-options instead of -D foo=bar.

dwijnand commented 4 years ago

The current setup is to workaround https://github.com/coursier/coursier/issues/1519. Are you saying that resolved?

lrytz commented 4 years ago

Seems so, at least for me, using the scala-runner version of this PR

➜  scala-runners git:(minusJ) ./scala -Dfoo.bar=baz -e 'println(System.getProperty("foo.bar"))'
baz
lrytz commented 4 years ago

That's with

➜  scala-runners git:(minusJ) cs --help
Coursier 2.0.0-RC6-11
dwijnand commented 4 years ago

Cool, looks like this is definitely a net improvement, seeing as it fixes -Dscala.color too.

$ cs launch scala -Dfoo=bar -- -e 'println(sys.props("foo"))'
Unrecognized argument: -Dfoo=bar
$ cs launch scala -J-Dfoo=bar -- -e 'println(sys.props("foo"))'
Unrecognized argument: -J-Dfoo=bar
$ cs launch scala -Dscala.color -- -e 'println(sys.props.get("scala.color"))'
Unrecognized argument: -Dscala.color
$ cs launch scala -J-Dscala.color -- -e 'println(sys.props.get("scala.color"))'
Unrecognized argument: -J-Dscala.color
$ cs launch scala -D scala.color -- -e 'println(sys.props.get("scala.color"))'
Malformed property argument 'scala.color' (expected name=value)
$
$ cs launch scala -J -Dfoo=bar -- -e 'println(sys.props("foo"))'
bar
$ cs launch scala -J -Dscala.color -- -e 'println(sys.props.get("scala.color"))'
Some()