From d2af62e6c35583fafa2f39e9c204fad6a21b38ab Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sat, 29 Jun 2019 22:44:09 -0700 Subject: Delegate to `./mill` wrapper script from launcher Only delegate if the file exists, and we are not currently being delegated to. This makes the installed launcher automatically download the correct version of itself to run the build, assuming a `./mill` wrapper script exists --- build.sc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/build.sc b/build.sc index aed391d4..dce241b9 100755 --- a/build.sc +++ b/build.sc @@ -444,7 +444,16 @@ def launcherScript(shellJvmArgs: Seq[String], def java(mainClass: String) = s"""exec $$JAVACMD $jvmArgsStr $$JAVA_OPTS -cp "${shellClassPath.mkString(":")}" $mainClass "$$@"""" - s"""if [ -z "$$JAVA_HOME" ] ; then + // Delegate to the `./mill` wrapper script if one exists, and we are being + // called manually (i.e. the MILL_EXEC_PATH that the wrapper script normally + // sets is not present in the environment) + s"""if [ -f "$$(dirname "$$BASH_SOURCE")/mill" ] ; then + | if [ ! -z "$$MILL_EXEC_PATH" ] ; then + | exec "$$(dirname "$$BASH_SOURCE")/mill" + | fi + |fi + | + |if [ -z "$$JAVA_HOME" ] ; then | JAVACMD="java" |else | JAVACMD="$$JAVA_HOME/bin/java" -- cgit v1.2.3