mirror of https://github.com/sbt/sbt.git
Partition system and app args to bootstrapped executable (#852)
This commit is contained in:
parent
a5b0424c08
commit
e4f40b6a1d
|
|
@ -68,18 +68,37 @@ object Bootstrap extends CaseApp[BootstrapOptions] {
|
||||||
|
|
||||||
private def createJarBootstrapWithPreamble(javaOpts: Seq[String], output: File, content: Array[Byte]): Unit = {
|
private def createJarBootstrapWithPreamble(javaOpts: Seq[String], output: File, content: Array[Byte]): Unit = {
|
||||||
|
|
||||||
|
val argsPartitioner =
|
||||||
|
"""|sys_args=""
|
||||||
|
|app_args=""
|
||||||
|
|i=1; while [ "$i" -le $# ]; do
|
||||||
|
| eval arg=\${$i}
|
||||||
|
| case $arg in
|
||||||
|
| -J-*)
|
||||||
|
| sys_args="$sys_args ${arg#-J}"
|
||||||
|
| ;;
|
||||||
|
| *)
|
||||||
|
| app_args="$app_args $arg"
|
||||||
|
| ;;
|
||||||
|
| esac
|
||||||
|
| i=$((i + 1))
|
||||||
|
|done
|
||||||
|
|""".stripMargin
|
||||||
|
|
||||||
val javaCmd = Seq("java") ++
|
val javaCmd = Seq("java") ++
|
||||||
javaOpts
|
javaOpts
|
||||||
// escaping possibly a bit loose :-|
|
// escaping possibly a bit loose :-|
|
||||||
.map(s => "'" + s.replace("'", "\\'") + "'") ++
|
.map(s => "'" + s.replace("'", "\\'") + "'") ++
|
||||||
Seq(
|
Seq(
|
||||||
|
"$sys_args",
|
||||||
"-jar",
|
"-jar",
|
||||||
"\"$0\"",
|
"\"$0\"",
|
||||||
"\"$@\""
|
"$app_args"
|
||||||
)
|
)
|
||||||
|
|
||||||
val shellPreamble = Seq(
|
val shellPreamble = Seq(
|
||||||
"#!/usr/bin/env sh",
|
"#!/usr/bin/env sh",
|
||||||
|
argsPartitioner,
|
||||||
"exec " + javaCmd.mkString(" ")
|
"exec " + javaCmd.mkString(" ")
|
||||||
).mkString("", "\n", "\n")
|
).mkString("", "\n", "\n")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,11 @@ testBootstrap() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$(./cs-echo-launcher -J-Dother=thing foo -J-Dfoo=baz)" != foo ]; then
|
||||||
|
echo "Error: unexpected output from bootstrapped echo command (generated by proguarded launcher)." 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# run via the launcher rather than via the sbt-pack scripts, because the latter interprets -Dfoo=baz itself
|
# run via the launcher rather than via the sbt-pack scripts, because the latter interprets -Dfoo=baz itself
|
||||||
# rather than passing it to coursier since https://github.com/xerial/sbt-pack/pull/118
|
# rather than passing it to coursier since https://github.com/xerial/sbt-pack/pull/118
|
||||||
./coursier-test bootstrap -o cs-props -D other=thing -J -Dfoo=baz io.get-coursier:props:1.0.2
|
./coursier-test bootstrap -o cs-props -D other=thing -J -Dfoo=baz io.get-coursier:props:1.0.2
|
||||||
|
|
@ -150,6 +155,11 @@ testBootstrap() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$(./cs-props -J-Dhappy=days happy)" != days ]; then
|
||||||
|
echo "Error: unexpected output from bootstrapped props command." 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# assembly tests
|
# assembly tests
|
||||||
./coursier-test bootstrap -a -o cs-props-assembly -D other=thing -J -Dfoo=baz io.get-coursier:props:1.0.2
|
./coursier-test bootstrap -a -o cs-props-assembly -D other=thing -J -Dfoo=baz io.get-coursier:props:1.0.2
|
||||||
local OUT="$(./cs-props-assembly foo)"
|
local OUT="$(./cs-props-assembly foo)"
|
||||||
|
|
@ -192,6 +202,8 @@ if isScalaJs; then
|
||||||
jsCompile
|
jsCompile
|
||||||
runJsTests
|
runJsTests
|
||||||
else
|
else
|
||||||
|
testBootstrap
|
||||||
|
|
||||||
testNativeBootstrap
|
testNativeBootstrap
|
||||||
|
|
||||||
integrationTestsRequirements
|
integrationTestsRequirements
|
||||||
|
|
@ -208,8 +220,6 @@ else
|
||||||
else
|
else
|
||||||
runJvmTests
|
runJvmTests
|
||||||
|
|
||||||
testBootstrap
|
|
||||||
|
|
||||||
validateReadme
|
validateReadme
|
||||||
checkBinaryCompatibility
|
checkBinaryCompatibility
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue