forked from VirtusLab/scala-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mill
executable file
·64 lines (54 loc) · 2.23 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
#!/usr/bin/env bash
# Adapted from
coursier_version="2.1.0-M6-53-gb4f448130"
# 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
eval "$("$cs" java --env --jvm temurin:17 || "$cs" java --env --jvm openjdk:1.17.0)"
# 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" "$@"