diff options
author | Jakob Odersky <jakob@inpher.io> | 2019-11-25 18:50:48 -0500 |
---|---|---|
committer | Jakob Odersky <jakob@inpher.io> | 2019-11-25 18:50:48 -0500 |
commit | 1bc0a6b4727feca25d615ea2c0dbe608cdd1a9a1 (patch) | |
tree | 07b507cd1370a31345548fbaa5a04b3ef19dfb09 | |
download | scala-tutorial-1bc0a6b4727feca25d615ea2c0dbe608cdd1a9a1.tar.gz scala-tutorial-1bc0a6b4727feca25d615ea2c0dbe608cdd1a9a1.tar.bz2 scala-tutorial-1bc0a6b4727feca25d615ea2c0dbe608cdd1a9a1.zip |
Prepare build tool
-rw-r--r-- | .mill-version | 1 | ||||
-rwxr-xr-x | mill | 44 |
2 files changed, 45 insertions, 0 deletions
diff --git a/.mill-version b/.mill-version new file mode 100644 index 0000000..2411653 --- /dev/null +++ b/.mill-version @@ -0,0 +1 @@ +0.5.2
\ No newline at end of file @@ -0,0 +1,44 @@ +#!/usr/bin/env sh + +# This is a wrapper script, that automatically download mill from GitHub release pages +# You can give the required mill version with MILL_VERSION env variable +# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION +DEFAULT_MILL_VERSION=0.5.2 + +set -e + +if [ -z "$MILL_VERSION" ] ; then + if [ -f ".mill-version" ] ; then + MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)" + elif [ -f "mill" ] && [ "$BASH_SOURCE" != "mill" ] ; then + MILL_VERSION=$(grep -F "DEFAULT_MILL_VERSION=" "mill" | head -n 1 | cut -d= -f2) + else + MILL_VERSION=$DEFAULT_MILL_VERSION + fi +fi + +MILL_DOWNLOAD_PATH="$HOME/.mill/download" +MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/$MILL_VERSION" + +version_remainder="$MILL_VERSION" +MILL_MAJOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}" +MILL_MINOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}" + +if [ ! -x "$MILL_EXEC_PATH" ] ; then + mkdir -p $MILL_DOWNLOAD_PATH + if [ $MILL_MAJOR_VERSION -gt 0 ] || [ $MILL_MINOR_VERSION -ge 5 ] ; then + ASSEMBLY="-assembly" + fi + DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download + MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION%%-*}/$MILL_VERSION${ASSEMBLY}" + curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL" + chmod +x "$DOWNLOAD_FILE" + mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH" + unset DOWNLOAD_FILE + unset MILL_DOWNLOAD_URL +fi + +unset MILL_DOWNLOAD_PATH +unset MILL_VERSION + +exec $MILL_EXEC_PATH "$@" |