If there are strings in the path name, the sbt-script argument will be
interpreted as multiple arguments. The thin client also needs to be
updated to handle %20 in path names.
Passing the unsanitized arguments was problematic in sbt.bat because it
caused sbt --client to run sbtn with --client as a parameter. This
caused sbtn to launch sbt with the --client which caused a loop. This
manifested as a weird error about not being able to get the console
mode.
There are scenarios where sbt is not on the path and may be invoked as
an absolute path from the shell. When this is the case, sbtn will fail
to start a server because of the missing sbt on the path. We can fix
this by setting the --sbt-script parameter.
Before:
```
$ time sbt --client exit
[info] entering *experimental* thin client - BEEP WHIRR
[info] terminate the server with `shutdown`
sbt --client exit 0.16s user 0.15s system 101% cpu 0.303 total
```
sbt --client was running around 303ms (median out of 5) on my machine.
```
$ time sbtn exit
[info] entering *experimental* thin client - BEEP WHIRR
[info] terminate the server with `shutdown`
sbtn exit 0.05s user 0.05s system 112% cpu 0.085 total
```
On the other hand, sbtn ran in 85ms (median out of 5).
After:
```
$ time ~/work/sbt-modules/sbt-launcher-package/target/universal/stage/bin/sbt --client exit
[info] entering *experimental* thin client - BEEP WHIRR
[info] terminate the server with `shutdown`
~/work/sbt-modules/sbt-launcher-package/target/universal/stage/bin/sbt exit 0.06s user 0.08s system 111% cpu 0.127 total
```
By delaying the java version detection, I got it down to 127ms.
Using `--no-share` as a command line option resulted in a single additional
argument added to the java command:
`-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy`
Actually, three separate arguments need to be added.
Ref https://github.com/sbt/sbt/issues/5665
This implements `--client` option to use `sbt` script as the sbtn runner. The build user can also set the env variable `SBT_NATIVE_CLIENT` to `true`.
The script will attempt to parse `project/build.properties` and use sbtn only when it's sbt 1.4 or above.
Solves the issue where providing sbt_options and java_args containing whitespaces on Java 9 and higher would fail. Expansion of sbt_options and java_args containing whitespaces would not expand correctly in copyRt(), but instead would create an invalid java command due to missing quotes.
Fixes https://github.com/sbt/sbt/issues/5035
Currently `sbt` calls `rsync -a`, which expands to `-rlptgoD`, including `--group` and `--owner` flag that preserves the group and owner of the files. This drops the requirement since we just need to copy files around with the right timestamp.
This allows, for example, capturing the correct PID when launching sbt
from within a bash script. The original change from
1a07150560 was to address an issue
specific to cygwin.
Fixessbt/sbt#2695
By the time the arguments are passed to a batch script,
it seems like is parsed away.
for /F did not work since it would not handle double quoted
paths that include whitespaces.
This adds special handling for -D parameters only.