diff --git a/.gitignore b/.gitignore index 100086e..d93ce81 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ cs .metals/ .bloop/ .idea* +.bsp diff --git a/.mill-version b/.mill-version deleted file mode 100644 index 78bc1ab..0000000 --- a/.mill-version +++ /dev/null @@ -1 +0,0 @@ -0.10.0 diff --git a/.scalafmt.conf b/.scalafmt.conf index 43e9529..a0fa1d8 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,2 +1,2 @@ -version = 3.4.3 +version = "3.8.3" runner.dialect = scala213source3 diff --git a/build.sc b/build.sc index c83d2ab..d2b9c48 100644 --- a/build.sc +++ b/build.sc @@ -1,34 +1,44 @@ +//| mill-version: 1.0.3 + // -*- mode: scala -*- +package build -import mill._, os._, scalalib._, publish._ +import mill.*, os.*, scalalib.*, publish.* +import mill.util.BuildInfo.{millVersion, millBinPlatform} import scala.util.Properties object meta { - val crossVersions = Seq("2.13.8") - - implicit val wd: Path = pwd - def nonEmpty(s: String): Option[String] = s.trim match { case v if v.isEmpty => None - case v => Some(v) + case v => Some(v) } - val MILL_VERSION = Properties.propOrNull("MILL_VERSION") val versionFromEnv = Properties.propOrNone("PUBLISH_VERSION") - val gitSha = nonEmpty(proc("git", "rev-parse", "--short", "HEAD").call().out.trim) - val gitTag = nonEmpty(proc("git", "tag", "-l", "-n0", "--points-at", "HEAD").call().out.trim) - val publishVersion = (versionFromEnv orElse gitTag orElse gitSha).getOrElse("latest") + val gitSha = nonEmpty( + os.call(Seq("git", "rev-parse", "--short", "HEAD")).out.text().trim() + ) + val gitTag = nonEmpty( + os.call(Seq("git", "tag", "-l", "-n0", "--points-at", "HEAD")) + .out + .text() + .trim() + ) + val publishVersion = + (versionFromEnv orElse gitTag orElse gitSha).getOrElse("latest") } -object dotenv extends Cross[Dotenv](meta.crossVersions: _*) -class Dotenv(val crossScalaVersion: String) extends CrossScalaModule with PublishModule { self => - def publishVersion = meta.publishVersion +object dotenv extends ScalaModule with PublishModule { + + override def scalaVersion = "3.7.1" - def artifactName = "mill-dotenv" + override def publishVersion = meta.publishVersion - def pomSettings = PomSettings( - description = "mill support for twelve-factor apps. load environment variables from .env", + override def artifactName = "mill-dotenv" + + override def pomSettings = PomSettings( + description = + "mill support for twelve-factor apps. load environment variables from .env", organization = "com.github.vic", url = "https://github.com/vic/mill-dotenv", licenses = Seq(License.`Apache-2.0`), @@ -38,11 +48,9 @@ class Dotenv(val crossScalaVersion: String) extends CrossScalaModule with Publis ) ) - def compileIvyDeps = Agg( - ivy"com.lihaoyi::mill-scalalib:${meta.MILL_VERSION}" - ) + override def mvnDeps = Seq(mvn"com.lihaoyi::mill-libs:$millVersion") - object tests extends Tests with TestModule.Utest { - def ivyDeps = Agg(ivy"com.lihaoyi::utest:0.7.11") ++ self.compileIvyDeps() + object tests extends ScalaTests, TestModule.Utest { + override def mvnDeps = Seq(mvn"com.lihaoyi::mill-testkit:$millVersion") } } diff --git a/ci b/ci index fe977d8..21f811e 100755 --- a/ci +++ b/ci @@ -11,35 +11,27 @@ function die { case "$1" in jitpack) - exec $0 mill -j 0 __.publishM2Local + $BASE_DIR/mill -j 0 __.publishM2Local ;; mill) - exec $0 cs launch --scala 2.13.8 mill -- "${@:2}" + $BASE_DIR/mill "${@:2}" ;; mill-i) - exec $0 cs launch --scala 2.13.8 mill-interactive -- -i "${@:2}" + $BASE_DIR/mill -i "${@:2}" ;; scalafmt) - exec $0 cs launch --scala 2.13.8 scalafmt -- --diff "${@:2}" + $0 mill mill.scalalib.scalafmt/ ;; scalafmt-test) - $0 scalafmt --test - ;; - - cs) - test -x $BASE_DIR/cs || { - curl -o $BASE_DIR/cs -qL https://git.io/coursier-cli - chmod +x $BASE_DIR/cs - } - exec $BASE_DIR/cs "${@:2}" + $0 mill mill.scalalib.scalafmt/checkFormatAll ;; example) - $0 mill-i -j 0 -D PUBLISH_VERSION=latest __.publishLocal + $0 mill-i -j 0 -DPUBLISH_VERSION=latest __.publishLocal (cd example; ../ci mill hello.run) (cd example; ../ci mill hello.tests) ;; diff --git a/dotenv/src/DotEnvModule.scala b/dotenv/src/DotEnvModule.scala index 5016b30..91d1e1a 100644 --- a/dotenv/src/DotEnvModule.scala +++ b/dotenv/src/DotEnvModule.scala @@ -1,23 +1,29 @@ package mill.dotenv import mill._ -import scalalib._ - +import mill.scalalib._ +import os.Path +import mill.api.BuildCtx object DotEnvModule { - def parse(pathRef: PathRef):Map[String,String] = { + def parse(pathRef: PathRef): Map[String, String] = { parse(os.read(pathRef.path)) } - def parse(source: String): Map[String, String] = LINE_REGEX.findAllMatchIn(source) - .map(keyValue => (keyValue.group(1), unescapeCharacters(removeQuotes(keyValue.group(2))))) + def parse(source: String): Map[String, String] = LINE_REGEX + .findAllMatchIn(source) + .map(keyValue => + (keyValue.group(1), unescapeCharacters(removeQuotes(keyValue.group(2)))) + ) .toMap private def removeQuotes(value: String): String = { value.trim match { - case quoted if quoted.startsWith("'") && quoted.endsWith("'") => quoted.substring(1, quoted.length - 1) - case quoted if quoted.startsWith("\"") && quoted.endsWith("\"") => quoted.substring(1, quoted.length - 1) + case quoted if quoted.startsWith("'") && quoted.endsWith("'") => + quoted.substring(1, quoted.length - 1) + case quoted if quoted.startsWith("\"") && quoted.endsWith("\"") => + quoted.substring(1, quoted.length - 1) case unquoted => unquoted } } @@ -54,16 +60,19 @@ object DotEnvModule { (?:$|\z) # end of line """.r - } -trait DotEnvModule extends JavaModule { +trait DotEnvModule extends mill.javalib.JavaModule { - def dotenvSources = T.sources { os.pwd / ".env" } + def dotenvSources = Task.Sources { BuildCtx.workspaceRoot / ".env" } - def dotenv = T.input { - dotenvSources().map(DotEnvModule.parse).foldLeft(Map[String,String]()) { _ ++ _ } - } + def dotenv = dotenvSources + .map( + _.map(DotEnvModule.parse) + .foldLeft(Map[String, String]()) { + _ ++ _ + } + ) override def forkEnv = super.forkEnv() ++ dotenv() } diff --git a/dotenv/tests/src/DotEnvModuleTests.scala b/dotenv/tests/src/DotEnvModuleTests.scala index e58e37f..d74f4c6 100644 --- a/dotenv/tests/src/DotEnvModuleTests.scala +++ b/dotenv/tests/src/DotEnvModuleTests.scala @@ -5,26 +5,38 @@ import utest._ object DotEnvModuleTests extends TestSuite { val tests = Tests { - "should remove quotes from value" - { - assert_env("HELLO", "WORLD", """ + test("should remove quotes from value") - { + assert_env( + "HELLO", + "WORLD", + """ HELLO="WORLD" -""") +""" + ) } - "should allow dot as key name" - { - assert_env("HELL.O", "WORLD", """ + test("should allow dot as key name") - { + assert_env( + "HELL.O", + "WORLD", + """ HELL.O=WORLD -""") +""" + ) } - "should allow new lines on value" - { - assert_env("HELLO", "BEAUTIFUL\nWORLD", """ + test("should allow new lines on value") - { + assert_env( + "HELLO", + "BEAUTIFUL\nWORLD", + """ HELLO="BEAUTIFUL WORLD" -""") +""" + ) } - "should ignore commented values" - { + test("should ignore commented values") - { val env = DotEnvModule.parse("#FOO=BAR") assert(None == env.get("FOO")) } diff --git a/example/build.sc b/example/build.sc index 614cc1b..974d805 100644 --- a/example/build.sc +++ b/example/build.sc @@ -1,20 +1,24 @@ -// -*- mode: scala -*- +//| mvnDeps: ["com.github.vic::mill-dotenv:latest"] +//| mill-version: 1.0.3 -import $ivy.`com.github.vic::mill-dotenv:latest` // Change to fixed release +// -*- mode: scala -*- +package build import mill._, scalalib._, mill.dotenv._ +import mill.api.BuildCtx object hello extends ScalaModule with DotEnvModule { override def scalaVersion = scala.util.Properties.versionNumberString - override def finalMainClass = T("hello.Main") + override def finalMainClass = Task("hello.Main") // by default dotenv will read `$PWD/.env` file // unless `def dotenvSources` is overriden. - object tests extends Tests with DotEnvModule with TestModule.Utest { + object tests extends ScalaTests with DotEnvModule with TestModule.Utest { // load.env-test for test environment - override def dotenvSources = T.sources { os.pwd / ".env-test" } - - def ivyDeps = Agg(ivy"com.lihaoyi::utest::0.7.11") + override def dotenvSources = Task.Sources { + BuildCtx.workspaceRoot / ".env-test" + } + override def mvnDeps = Seq(mvn"com.lihaoyi::utest:0.9.0") } } diff --git a/example/hello/tests/src/HelloTests.scala b/example/hello/tests/src/HelloTests.scala index ecc649f..253f663 100644 --- a/example/hello/tests/src/HelloTests.scala +++ b/example/hello/tests/src/HelloTests.scala @@ -3,8 +3,8 @@ package hello import utest._ object HelloTests extends TestSuite { - val tests = Tests{ - 'world - { + val tests = Tests { + test("world") - { assert("monde" == sys.env("WORLD")) } } diff --git a/mill b/mill new file mode 100755 index 0000000..4a0cb64 --- /dev/null +++ b/mill @@ -0,0 +1,333 @@ +#!/usr/bin/env sh + +# This is a wrapper script, that automatically selects or downloads Mill from Maven Central or GitHub release pages. +# +# This script determines the Mill version to use by trying these sources +# - env-variable `MILL_VERSION` +# - local file `.mill-version` +# - local file `.config/mill-version` +# - `mill-version` from YAML fronmatter of current buildfile +# - if accessible, find the latest stable version available on Maven Central (https://repo1.maven.org/maven2) +# - env-variable `DEFAULT_MILL_VERSION` +# +# If a version has the suffix '-native' a native binary will be used. +# If a version has the suffix '-jvm' an executable jar file will be used, requiring an already installed Java runtime. +# If no such suffix is found, the script will pick a default based on version and platform. +# +# Once a version was determined, it tries to use either +# - a system-installed mill, if found and it's version matches +# - an already downloaded version under ~/.cache/mill/download +# +# If no working mill version was found on the system, +# this script downloads a binary file from Maven Central or Github Pages (this is version dependent) +# into a cache location (~/.cache/mill/download). +# +# Mill Project URL: https://github.com/com-lihaoyi/mill +# Script Version: 1.0.0-M1-21-7b6fae-DIRTY892b63e8 +# +# If you want to improve this script, please also contribute your changes back! +# This script was generated from: dist/scripts/src/mill.sh +# +# Licensed under the Apache License, Version 2.0 + +set -e + +if [ "$1" = "--setup-completions" ] ; then + # Need to preserve the first position of those listed options + MILL_FIRST_ARG=$1 + shift +fi + +if [ -z "${DEFAULT_MILL_VERSION}" ] ; then + DEFAULT_MILL_VERSION="0.12.10" +fi + + +if [ -z "${GITHUB_RELEASE_CDN}" ] ; then + GITHUB_RELEASE_CDN="" +fi + + +MILL_REPO_URL="https://github.com/com-lihaoyi/mill" + +if [ -z "${CURL_CMD}" ] ; then + CURL_CMD=curl +fi + +# Explicit commandline argument takes precedence over all other methods +if [ "$1" = "--mill-version" ] ; then + echo "The --mill-version option is no longer supported." 1>&2 +fi + +MILL_BUILD_SCRIPT="" + +if [ -f "build.mill" ] ; then + MILL_BUILD_SCRIPT="build.mill" +elif [ -f "build.mill.scala" ] ; then + MILL_BUILD_SCRIPT="build.mill.scala" +elif [ -f "build.sc" ] ; then + MILL_BUILD_SCRIPT="build.sc" +fi + +# Please note, that if a MILL_VERSION is already set in the environment, +# We reuse it's value and skip searching for a value. + +# If not already set, read .mill-version file +if [ -z "${MILL_VERSION}" ] ; then + if [ -f ".mill-version" ] ; then + MILL_VERSION="$(tr '\r' '\n' < .mill-version | head -n 1 2> /dev/null)" + elif [ -f ".config/mill-version" ] ; then + MILL_VERSION="$(tr '\r' '\n' < .config/mill-version | head -n 1 2> /dev/null)" + elif [ -n "${MILL_BUILD_SCRIPT}" ] ; then + MILL_VERSION="$(cat ${MILL_BUILD_SCRIPT} | grep '//[|] *mill-version: *' | sed 's;//| *mill-version: *;;')" + fi +fi + +MILL_USER_CACHE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/mill" + +if [ -z "${MILL_DOWNLOAD_PATH}" ] ; then + MILL_DOWNLOAD_PATH="${MILL_USER_CACHE_DIR}/download" +fi + +# If not already set, try to fetch newest from Github +if [ -z "${MILL_VERSION}" ] ; then + # TODO: try to load latest version from release page + echo "No mill version specified." 1>&2 + echo "You should provide a version via a '//| mill-version: ' comment or a '.mill-version' file." 1>&2 + + mkdir -p "${MILL_DOWNLOAD_PATH}" + LANG=C touch -d '1 hour ago' "${MILL_DOWNLOAD_PATH}/.expire_latest" 2>/dev/null || ( + # we might be on OSX or BSD which don't have -d option for touch + # but probably a -A [-][[hh]mm]SS + touch "${MILL_DOWNLOAD_PATH}/.expire_latest"; touch -A -010000 "${MILL_DOWNLOAD_PATH}/.expire_latest" + ) || ( + # in case we still failed, we retry the first touch command with the intention + # to show the (previously suppressed) error message + LANG=C touch -d '1 hour ago' "${MILL_DOWNLOAD_PATH}/.expire_latest" + ) + + # POSIX shell variant of bash's -nt operator, see https://unix.stackexchange.com/a/449744/6993 + # if [ "${MILL_DOWNLOAD_PATH}/.latest" -nt "${MILL_DOWNLOAD_PATH}/.expire_latest" ] ; then + if [ -n "$(find -L "${MILL_DOWNLOAD_PATH}/.latest" -prune -newer "${MILL_DOWNLOAD_PATH}/.expire_latest")" ]; then + # we know a current latest version + MILL_VERSION=$(head -n 1 "${MILL_DOWNLOAD_PATH}"/.latest 2> /dev/null) + fi + + if [ -z "${MILL_VERSION}" ] ; then + # we don't know a current latest version + echo "Retrieving latest mill version ..." 1>&2 + LANG=C ${CURL_CMD} -s -i -f -I ${MILL_REPO_URL}/releases/latest 2> /dev/null | grep --ignore-case Location: | sed s'/^.*tag\///' | tr -d '\r\n' > "${MILL_DOWNLOAD_PATH}/.latest" + MILL_VERSION=$(head -n 1 "${MILL_DOWNLOAD_PATH}"/.latest 2> /dev/null) + fi + + if [ -z "${MILL_VERSION}" ] ; then + # Last resort + MILL_VERSION="${DEFAULT_MILL_VERSION}" + echo "Falling back to hardcoded mill version ${MILL_VERSION}" 1>&2 + else + echo "Using mill version ${MILL_VERSION}" 1>&2 + fi +fi + +MILL_NATIVE_SUFFIX="-native" +MILL_JVM_SUFFIX="-jvm" +FULL_MILL_VERSION=$MILL_VERSION +ARTIFACT_SUFFIX="" +set_artifact_suffix(){ + if [ "$(expr substr $(uname -s) 1 5 2>/dev/null)" = "Linux" ]; then + if [ "$(uname -m)" = "aarch64" ]; then + ARTIFACT_SUFFIX="-native-linux-aarch64" + else + ARTIFACT_SUFFIX="-native-linux-amd64" + fi + elif [ "$(uname)" = "Darwin" ]; then + if [ "$(uname -m)" = "arm64" ]; then + ARTIFACT_SUFFIX="-native-mac-aarch64" + else + ARTIFACT_SUFFIX="-native-mac-amd64" + fi + else + echo "This native mill launcher supports only Linux and macOS." 1>&2 + exit 1 + fi +} + +case "$MILL_VERSION" in + *"$MILL_NATIVE_SUFFIX") + MILL_VERSION=${MILL_VERSION%"$MILL_NATIVE_SUFFIX"} + set_artifact_suffix + ;; + + *"$MILL_JVM_SUFFIX") + MILL_VERSION=${MILL_VERSION%"$MILL_JVM_SUFFIX"} + ;; + + *) + case "$MILL_VERSION" in + 0.1.*) ;; + 0.2.*) ;; + 0.3.*) ;; + 0.4.*) ;; + 0.5.*) ;; + 0.6.*) ;; + 0.7.*) ;; + 0.8.*) ;; + 0.9.*) ;; + 0.10.*) ;; + 0.11.*) ;; + 0.12.*) ;; + *) + set_artifact_suffix + esac + ;; +esac + +MILL="${MILL_DOWNLOAD_PATH}/$MILL_VERSION$ARTIFACT_SUFFIX" + +try_to_use_system_mill() { + if [ "$(uname)" != "Linux" ]; then + return 0 + fi + + MILL_IN_PATH="$(command -v mill || true)" + + if [ -z "${MILL_IN_PATH}" ]; then + return 0 + fi + + SYSTEM_MILL_FIRST_TWO_BYTES=$(head --bytes=2 "${MILL_IN_PATH}") + if [ "${SYSTEM_MILL_FIRST_TWO_BYTES}" = "#!" ]; then + # MILL_IN_PATH is (very likely) a shell script and not the mill + # executable, ignore it. + return 0 + fi + + SYSTEM_MILL_PATH=$(readlink -e "${MILL_IN_PATH}") + SYSTEM_MILL_SIZE=$(stat --format=%s "${SYSTEM_MILL_PATH}") + SYSTEM_MILL_MTIME=$(stat --format=%y "${SYSTEM_MILL_PATH}") + + if [ ! -d "${MILL_USER_CACHE_DIR}" ]; then + mkdir -p "${MILL_USER_CACHE_DIR}" + fi + + SYSTEM_MILL_INFO_FILE="${MILL_USER_CACHE_DIR}/system-mill-info" + if [ -f "${SYSTEM_MILL_INFO_FILE}" ]; then + parseSystemMillInfo() { + LINE_NUMBER="${1}" + # Select the line number of the SYSTEM_MILL_INFO_FILE, cut the + # variable definition in that line in two halves and return + # the value, and finally remove the quotes. + sed -n "${LINE_NUMBER}p" "${SYSTEM_MILL_INFO_FILE}" |\ + cut -d= -f2 |\ + sed 's/"\(.*\)"/\1/' + } + + CACHED_SYSTEM_MILL_PATH=$(parseSystemMillInfo 1) + CACHED_SYSTEM_MILL_VERSION=$(parseSystemMillInfo 2) + CACHED_SYSTEM_MILL_SIZE=$(parseSystemMillInfo 3) + CACHED_SYSTEM_MILL_MTIME=$(parseSystemMillInfo 4) + + if [ "${SYSTEM_MILL_PATH}" = "${CACHED_SYSTEM_MILL_PATH}" ] \ + && [ "${SYSTEM_MILL_SIZE}" = "${CACHED_SYSTEM_MILL_SIZE}" ] \ + && [ "${SYSTEM_MILL_MTIME}" = "${CACHED_SYSTEM_MILL_MTIME}" ]; then + if [ "${CACHED_SYSTEM_MILL_VERSION}" = "${MILL_VERSION}" ]; then + MILL="${SYSTEM_MILL_PATH}" + return 0 + else + return 0 + fi + fi + fi + + SYSTEM_MILL_VERSION=$(${SYSTEM_MILL_PATH} --version | head -n1 | sed -n 's/^Mill.*version \(.*\)/\1/p') + + cat < "${SYSTEM_MILL_INFO_FILE}" +CACHED_SYSTEM_MILL_PATH="${SYSTEM_MILL_PATH}" +CACHED_SYSTEM_MILL_VERSION="${SYSTEM_MILL_VERSION}" +CACHED_SYSTEM_MILL_SIZE="${SYSTEM_MILL_SIZE}" +CACHED_SYSTEM_MILL_MTIME="${SYSTEM_MILL_MTIME}" +EOF + + if [ "${SYSTEM_MILL_VERSION}" = "${MILL_VERSION}" ]; then + MILL="${SYSTEM_MILL_PATH}" + fi +} +try_to_use_system_mill + +# If not already downloaded, download it +if [ ! -s "${MILL}" ] || [ "$MILL_TEST_DRY_RUN_LAUNCHER_SCRIPT" = "1" ] ; then + case $MILL_VERSION in + 0.0.* | 0.1.* | 0.2.* | 0.3.* | 0.4.* ) + DOWNLOAD_SUFFIX="" + DOWNLOAD_FROM_MAVEN=0 + ;; + 0.5.* | 0.6.* | 0.7.* | 0.8.* | 0.9.* | 0.10.* | 0.11.0-M* ) + DOWNLOAD_SUFFIX="-assembly" + DOWNLOAD_FROM_MAVEN=0 + ;; + *) + DOWNLOAD_SUFFIX="-assembly" + DOWNLOAD_FROM_MAVEN=1 + ;; + esac + case $MILL_VERSION in + 0.12.0 | 0.12.1 | 0.12.2 | 0.12.3 | 0.12.4 | 0.12.5 | 0.12.6 | 0.12.7 | 0.12.8 | 0.12.9 | 0.12.10 | 0.12.11 ) + DOWNLOAD_EXT="jar" + ;; + 0.12.* ) + DOWNLOAD_EXT="exe" + ;; + 0.* ) + DOWNLOAD_EXT="jar" + ;; + *) + DOWNLOAD_EXT="exe" + ;; + esac + + DOWNLOAD_FILE=$(mktemp mill.XXXXXX) + if [ "$DOWNLOAD_FROM_MAVEN" = "1" ] ; then + DOWNLOAD_URL="https://repo1.maven.org/maven2/com/lihaoyi/mill-dist${ARTIFACT_SUFFIX}/${MILL_VERSION}/mill-dist${ARTIFACT_SUFFIX}-${MILL_VERSION}.${DOWNLOAD_EXT}" + else + MILL_VERSION_TAG=$(echo "$MILL_VERSION" | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/') + DOWNLOAD_URL="${GITHUB_RELEASE_CDN}${MILL_REPO_URL}/releases/download/${MILL_VERSION_TAG}/${MILL_VERSION}${DOWNLOAD_SUFFIX}" + unset MILL_VERSION_TAG + fi + + if [ "$MILL_TEST_DRY_RUN_LAUNCHER_SCRIPT" = "1" ] ; then + echo $DOWNLOAD_URL + echo $MILL + exit 0 + fi + # TODO: handle command not found + echo "Downloading mill ${MILL_VERSION} from ${DOWNLOAD_URL} ..." 1>&2 + ${CURL_CMD} -f -L -o "${DOWNLOAD_FILE}" "${DOWNLOAD_URL}" + chmod +x "${DOWNLOAD_FILE}" + mkdir -p "${MILL_DOWNLOAD_PATH}" + mv "${DOWNLOAD_FILE}" "${MILL}" + + unset DOWNLOAD_FILE + unset DOWNLOAD_SUFFIX +fi + +if [ -z "$MILL_MAIN_CLI" ] ; then + MILL_MAIN_CLI="${0}" +fi + +MILL_FIRST_ARG="" +if [ "$1" = "--bsp" ] || [ "${1#"-i"}" != "$1" ] || [ "$1" = "--interactive" ] || [ "$1" = "--no-server" ] || [ "$1" = "--no-daemon" ] || [ "$1" = "--repl" ] || [ "$1" = "--help" ] ; then + # Need to preserve the first position of those listed options + MILL_FIRST_ARG=$1 + shift +fi + +unset MILL_DOWNLOAD_PATH +unset MILL_OLD_DOWNLOAD_PATH +unset OLD_MILL +unset MILL_VERSION +unset MILL_REPO_URL + +# -D mill.main.cli is for compatibility with Mill 0.10.9 - 0.13.0-M2 +# We don't quote MILL_FIRST_ARG on purpose, so we can expand the empty value without quotes +# shellcheck disable=SC2086 +exec "${MILL}" $MILL_FIRST_ARG -D "mill.main.cli=${MILL_MAIN_CLI}" "$@"