forked from VirtusLab/scala-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mill
executable file
·78 lines (68 loc) · 2.7 KB
/
mill
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env bash
# Adapted from
coursier_version="2.1.10"
# https://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux/17072017#17072017
if [ "$(expr substr $(uname -s) 1 5 2>/dev/null)" == "Linux" ]; then
if [ "$(uname -m)" == "aarch64" ]; then
cs_url="https://github.com/coursier/coursier/releases/download/v$coursier_version/cs-aarch64-pc-linux.gz"
else
cs_url="https://github.com/coursier/coursier/releases/download/v$coursier_version/cs-x86_64-pc-linux.gz"
fi
cache_base="$HOME/.cache/coursier/v1"
elif [ "$(uname)" == "Darwin" ]; then
# TODO: remove once coursier-m1 and coursier mainline are merged
if [ "$(uname -p)" == "arm" ]; then
cs_url="https://github.com/VirtusLab/coursier-m1/releases/download/v$coursier_version/cs-aarch64-apple-darwin.gz"
else
cs_url="https://github.com/coursier/coursier/releases/download/v$coursier_version/cs-x86_64-apple-darwin.gz"
fi
cache_base="$HOME/Library/Caches/Coursier/v1"
else
# assuming Windows…
cs_url="https://github.com/coursier/coursier/releases/download/v$coursier_version/cs-x86_64-pc-win32.zip"
cache_base="$LOCALAPPDATA/Coursier/v1" # TODO Check that
ext=".exe"
do_chmod="0"
fi
cache_dest="$cache_base/$(echo "$cs_url" | sed 's@://@/@')"
if [ ! -f "$cache_dest" ]; then
mkdir -p "$(dirname "$cache_dest")"
tmp_dest="$cache_dest.tmp-setup"
echo "Downloading $cs_url"
curl -fLo "$tmp_dest" "$cs_url"
mv "$tmp_dest" "$cache_dest"
fi
if [[ "$cache_dest" == *.gz ]]; then
cs="$(dirname "$cache_dest")/$(basename "$cache_dest" .gz)"
if [ ! -f "$cs" ]; then
gzip -d < "$cache_dest" > "$cs"
fi
if [ ! -x "$cs" ]; then
chmod +x "$cs"
fi
elif [[ "$cache_dest" == *.zip ]]; then
cs="$(dirname "$cache_dest")/$(basename "$cache_dest" .zip).exe"
if [ ! -f "$cs" ]; then
unzip -p "$cache_dest" "$(basename "$cache_dest" .zip).exe" > "$cs"
fi
fi
function to_bash_syntax {
local S
for S in "$@" ; do
echo "$S" | sed -E -e 's#^set #export #' -e 's#%([A-Z_][A-Z_0-9]*)%#${\1}#g' | tr '\\' '/'
done
}
# necessary for Windows various shell environments
if [[ `uname | grep -E 'CYG*|MSYS*|MING*|UCRT*|ClANG*|GIT*'` ]]; then
# needed for coursier version < 2.1.8, harmless otherwise
IFS=$'\n'
eval "$(to_bash_syntax `"$cs" java --env --jvm temurin:17` || to_bash_syntax `"$cs" java --env --jvm openjdk:1.17.0`)"
unset IFS
else
eval "$("$cs" java --env --jvm temurin:17 || "$cs" java --env --jvm openjdk:1.17.0)"
fi
# temporary, until we pass JPMS options to native-image,
# see https://www.graalvm.org/release-notes/22_2/#native-image
export USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM=false
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
exec "$DIR/millw" "$@"