Skip to content

Commit a32b83e

Browse files
hughsimpsonivantopo
authored andcommitted
bump mill to 0.12.16, add java 25 to ci matrix, bump mill script to 1.0.5
1 parent fcb5234 commit a32b83e

File tree

3 files changed

+139
-65
lines changed

3 files changed

+139
-65
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
name: Java ${{ matrix.java }}
1313
strategy:
1414
matrix:
15-
java: [17, 21]
15+
java: [17, 21, 25]
1616
fail-fast: false
1717
steps:
1818
- uses: actions/checkout@v3

.mill-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.12.9
1+
0.12.16

mill

Lines changed: 137 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,39 @@
11
#!/usr/bin/env sh
22

3-
# This is a wrapper script, that automatically download mill from GitHub release pages
4-
# You can give the required mill version with --mill-version parameter
5-
# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION
3+
# This is a wrapper script, that automatically selects or downloads Mill from Maven Central or GitHub release pages.
64
#
7-
# Original Project page: https://github.com/lefou/millw
8-
# Script Version: 0.4.12
5+
# This script determines the Mill version to use by trying these sources
6+
# - env-variable `MILL_VERSION`
7+
# - local file `.mill-version`
8+
# - local file `.config/mill-version`
9+
# - `mill-version` from YAML frontmatter of current buildfile
10+
# - if accessible, find the latest stable version available on Maven Central (https://repo1.maven.org/maven2)
11+
# - env-variable `DEFAULT_MILL_VERSION`
12+
#
13+
# If a version has the suffix '-native' a native binary will be used.
14+
# If a version has the suffix '-jvm' an executable jar file will be used, requiring an already installed Java runtime.
15+
# If no such suffix is found, the script will pick a default based on version and platform.
16+
#
17+
# Once a version was determined, it tries to use either
18+
# - a system-installed mill, if found and it's version matches
19+
# - an already downloaded version under ~/.cache/mill/download
20+
#
21+
# If no working mill version was found on the system,
22+
# this script downloads a binary file from Maven Central or Github Pages (this is version dependent)
23+
# into a cache location (~/.cache/mill/download).
24+
#
25+
# Mill Project URL: https://github.com/com-lihaoyi/mill
26+
# Script Version: 1.0.5
927
#
1028
# If you want to improve this script, please also contribute your changes back!
29+
# This script was generated from: dist/scripts/src/mill.sh
1130
#
1231
# Licensed under the Apache License, Version 2.0
1332

1433
set -e
1534

1635
if [ -z "${DEFAULT_MILL_VERSION}" ] ; then
17-
DEFAULT_MILL_VERSION=0.12.9
36+
DEFAULT_MILL_VERSION="1.0.5"
1837
fi
1938

2039

@@ -31,16 +50,17 @@ fi
3150

3251
# Explicit commandline argument takes precedence over all other methods
3352
if [ "$1" = "--mill-version" ] ; then
34-
shift
35-
if [ "x$1" != "x" ] ; then
36-
MILL_VERSION="$1"
37-
shift
38-
else
39-
echo "You specified --mill-version without a version." 1>&2
40-
echo "Please provide a version that matches one provided on" 1>&2
41-
echo "${MILL_REPO_URL}/releases" 1>&2
42-
false
43-
fi
53+
echo "The --mill-version option is no longer supported." 1>&2
54+
fi
55+
56+
MILL_BUILD_SCRIPT=""
57+
58+
if [ -f "build.mill" ] ; then
59+
MILL_BUILD_SCRIPT="build.mill"
60+
elif [ -f "build.mill.scala" ] ; then
61+
MILL_BUILD_SCRIPT="build.mill.scala"
62+
elif [ -f "build.sc" ] ; then
63+
MILL_BUILD_SCRIPT="build.sc"
4464
fi
4565

4666
# Please note, that if a MILL_VERSION is already set in the environment,
@@ -52,6 +72,20 @@ if [ -z "${MILL_VERSION}" ] ; then
5272
MILL_VERSION="$(tr '\r' '\n' < .mill-version | head -n 1 2> /dev/null)"
5373
elif [ -f ".config/mill-version" ] ; then
5474
MILL_VERSION="$(tr '\r' '\n' < .config/mill-version | head -n 1 2> /dev/null)"
75+
elif [ -n "${MILL_BUILD_SCRIPT}" ] ; then
76+
# `s/.*://`:
77+
# This is a greedy match that removes everything from the beginning of the line up to (and including) the last
78+
# colon (:). This effectively isolates the value part of the declaration.
79+
#
80+
# `s/#.*//`:
81+
# This removes any comments at the end of the line.
82+
#
83+
# `s/['\"]//g`:
84+
# This removes all single and double quotes from the string, wherever they appear (g is for "global").
85+
#
86+
# `s/^[[:space:]]*//; s/[[:space:]]*$//`:
87+
# These two expressions trim any leading or trailing whitespace ([[:space:]] matches spaces and tabs).
88+
MILL_VERSION="$(grep -E "//\|.*mill-version" "${MILL_BUILD_SCRIPT}" | sed -E "s/.*://; s/#.*//; s/['\"]//g; s/^[[:space:]]*//; s/[[:space:]]*$//")"
5589
fi
5690
fi
5791

@@ -65,7 +99,7 @@ fi
6599
if [ -z "${MILL_VERSION}" ] ; then
66100
# TODO: try to load latest version from release page
67101
echo "No mill version specified." 1>&2
68-
echo "You should provide a version via '.mill-version' file or --mill-version option." 1>&2
102+
echo "You should provide a version via a '//| mill-version: ' comment or a '.mill-version' file." 1>&2
69103

70104
mkdir -p "${MILL_DOWNLOAD_PATH}"
71105
LANG=C touch -d '1 hour ago' "${MILL_DOWNLOAD_PATH}/.expire_latest" 2>/dev/null || (
@@ -102,11 +136,10 @@ if [ -z "${MILL_VERSION}" ] ; then
102136
fi
103137

104138
MILL_NATIVE_SUFFIX="-native"
139+
MILL_JVM_SUFFIX="-jvm"
105140
FULL_MILL_VERSION=$MILL_VERSION
106141
ARTIFACT_SUFFIX=""
107-
case "$MILL_VERSION" in
108-
*"$MILL_NATIVE_SUFFIX")
109-
MILL_VERSION=${MILL_VERSION%"$MILL_NATIVE_SUFFIX"}
142+
set_artifact_suffix(){
110143
if [ "$(expr substr $(uname -s) 1 5 2>/dev/null)" = "Linux" ]; then
111144
if [ "$(uname -m)" = "aarch64" ]; then
112145
ARTIFACT_SUFFIX="-native-linux-aarch64"
@@ -123,9 +156,39 @@ case "$MILL_VERSION" in
123156
echo "This native mill launcher supports only Linux and macOS." 1>&2
124157
exit 1
125158
fi
159+
}
160+
161+
case "$MILL_VERSION" in
162+
*"$MILL_NATIVE_SUFFIX")
163+
MILL_VERSION=${MILL_VERSION%"$MILL_NATIVE_SUFFIX"}
164+
set_artifact_suffix
165+
;;
166+
167+
*"$MILL_JVM_SUFFIX")
168+
MILL_VERSION=${MILL_VERSION%"$MILL_JVM_SUFFIX"}
169+
;;
170+
171+
*)
172+
case "$MILL_VERSION" in
173+
0.1.*) ;;
174+
0.2.*) ;;
175+
0.3.*) ;;
176+
0.4.*) ;;
177+
0.5.*) ;;
178+
0.6.*) ;;
179+
0.7.*) ;;
180+
0.8.*) ;;
181+
0.9.*) ;;
182+
0.10.*) ;;
183+
0.11.*) ;;
184+
0.12.*) ;;
185+
*)
186+
set_artifact_suffix
187+
esac
188+
;;
126189
esac
127190

128-
MILL="${MILL_DOWNLOAD_PATH}/${FULL_MILL_VERSION}"
191+
MILL="${MILL_DOWNLOAD_PATH}/$MILL_VERSION$ARTIFACT_SUFFIX"
129192

130193
try_to_use_system_mill() {
131194
if [ "$(uname)" != "Linux" ]; then
@@ -198,57 +261,67 @@ EOF
198261
try_to_use_system_mill
199262

200263
# If not already downloaded, download it
201-
if [ ! -s "${MILL}" ] ; then
202-
203-
# support old non-XDG download dir
204-
MILL_OLD_DOWNLOAD_PATH="${HOME}/.mill/download"
205-
OLD_MILL="${MILL_OLD_DOWNLOAD_PATH}/${MILL_VERSION}"
206-
if [ -x "${OLD_MILL}" ] ; then
207-
MILL="${OLD_MILL}"
264+
if [ ! -s "${MILL}" ] || [ "$MILL_TEST_DRY_RUN_LAUNCHER_SCRIPT" = "1" ] ; then
265+
case $MILL_VERSION in
266+
0.0.* | 0.1.* | 0.2.* | 0.3.* | 0.4.* )
267+
DOWNLOAD_SUFFIX=""
268+
DOWNLOAD_FROM_MAVEN=0
269+
;;
270+
0.5.* | 0.6.* | 0.7.* | 0.8.* | 0.9.* | 0.10.* | 0.11.0-M* )
271+
DOWNLOAD_SUFFIX="-assembly"
272+
DOWNLOAD_FROM_MAVEN=0
273+
;;
274+
*)
275+
DOWNLOAD_SUFFIX="-assembly"
276+
DOWNLOAD_FROM_MAVEN=1
277+
;;
278+
esac
279+
case $MILL_VERSION in
280+
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 )
281+
DOWNLOAD_EXT="jar"
282+
;;
283+
0.12.* )
284+
DOWNLOAD_EXT="exe"
285+
;;
286+
0.* )
287+
DOWNLOAD_EXT="jar"
288+
;;
289+
*)
290+
DOWNLOAD_EXT="exe"
291+
;;
292+
esac
293+
294+
DOWNLOAD_FILE=$(mktemp mill.XXXXXX)
295+
if [ "$DOWNLOAD_FROM_MAVEN" = "1" ] ; then
296+
DOWNLOAD_URL="https://repo1.maven.org/maven2/com/lihaoyi/mill-dist${ARTIFACT_SUFFIX}/${MILL_VERSION}/mill-dist${ARTIFACT_SUFFIX}-${MILL_VERSION}.${DOWNLOAD_EXT}"
208297
else
209-
case $MILL_VERSION in
210-
0.0.* | 0.1.* | 0.2.* | 0.3.* | 0.4.* )
211-
DOWNLOAD_SUFFIX=""
212-
DOWNLOAD_FROM_MAVEN=0
213-
;;
214-
0.5.* | 0.6.* | 0.7.* | 0.8.* | 0.9.* | 0.10.* | 0.11.0-M* )
215-
DOWNLOAD_SUFFIX="-assembly"
216-
DOWNLOAD_FROM_MAVEN=0
217-
;;
218-
*)
219-
DOWNLOAD_SUFFIX="-assembly"
220-
DOWNLOAD_FROM_MAVEN=1
221-
;;
222-
esac
223-
224-
DOWNLOAD_FILE=$(mktemp mill.XXXXXX)
225-
226-
if [ "$DOWNLOAD_FROM_MAVEN" = "1" ] ; then
227-
DOWNLOAD_URL="https://repo1.maven.org/maven2/com/lihaoyi/mill-dist${ARTIFACT_SUFFIX}/${MILL_VERSION}/mill-dist${ARTIFACT_SUFFIX}-${MILL_VERSION}.jar"
228-
else
229-
MILL_VERSION_TAG=$(echo "$MILL_VERSION" | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/')
230-
DOWNLOAD_URL="${GITHUB_RELEASE_CDN}${MILL_REPO_URL}/releases/download/${MILL_VERSION_TAG}/${MILL_VERSION}${DOWNLOAD_SUFFIX}"
231-
unset MILL_VERSION_TAG
232-
fi
233-
234-
# TODO: handle command not found
235-
echo "Downloading mill ${MILL_VERSION} from ${DOWNLOAD_URL} ..." 1>&2
236-
${CURL_CMD} -f -L -o "${DOWNLOAD_FILE}" "${DOWNLOAD_URL}"
237-
chmod +x "${DOWNLOAD_FILE}"
238-
mkdir -p "${MILL_DOWNLOAD_PATH}"
239-
mv "${DOWNLOAD_FILE}" "${MILL}"
298+
MILL_VERSION_TAG=$(echo "$MILL_VERSION" | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/')
299+
DOWNLOAD_URL="${GITHUB_RELEASE_CDN}${MILL_REPO_URL}/releases/download/${MILL_VERSION_TAG}/${MILL_VERSION}${DOWNLOAD_SUFFIX}"
300+
unset MILL_VERSION_TAG
301+
fi
240302

241-
unset DOWNLOAD_FILE
242-
unset DOWNLOAD_SUFFIX
303+
if [ "$MILL_TEST_DRY_RUN_LAUNCHER_SCRIPT" = "1" ] ; then
304+
echo $DOWNLOAD_URL
305+
echo $MILL
306+
exit 0
243307
fi
308+
# TODO: handle command not found
309+
echo "Downloading mill ${MILL_VERSION} from ${DOWNLOAD_URL} ..." 1>&2
310+
${CURL_CMD} -f -L -o "${DOWNLOAD_FILE}" "${DOWNLOAD_URL}"
311+
chmod +x "${DOWNLOAD_FILE}"
312+
mkdir -p "${MILL_DOWNLOAD_PATH}"
313+
mv "${DOWNLOAD_FILE}" "${MILL}"
314+
315+
unset DOWNLOAD_FILE
316+
unset DOWNLOAD_SUFFIX
244317
fi
245318

246319
if [ -z "$MILL_MAIN_CLI" ] ; then
247320
MILL_MAIN_CLI="${0}"
248321
fi
249322

250323
MILL_FIRST_ARG=""
251-
if [ "$1" = "--bsp" ] || [ "$1" = "-i" ] || [ "$1" = "--interactive" ] || [ "$1" = "--no-server" ] || [ "$1" = "--repl" ] || [ "$1" = "--help" ] ; then
324+
if [ "$1" = "--bsp" ] || [ "${1#"-i"}" != "$1" ] || [ "$1" = "--interactive" ] || [ "$1" = "--no-server" ] || [ "$1" = "--no-daemon" ] || [ "$1" = "--repl" ] || [ "$1" = "--help" ] ; then
252325
# Need to preserve the first position of those listed options
253326
MILL_FIRST_ARG=$1
254327
shift
@@ -260,6 +333,7 @@ unset OLD_MILL
260333
unset MILL_VERSION
261334
unset MILL_REPO_URL
262335

336+
# -D mill.main.cli is for compatibility with Mill 0.10.9 - 0.13.0-M2
263337
# We don't quote MILL_FIRST_ARG on purpose, so we can expand the empty value without quotes
264338
# shellcheck disable=SC2086
265-
exec "${MILL}" $MILL_FIRST_ARG -D "mill.main.cli=${MILL_MAIN_CLI}" "$@"
339+
exec "${MILL}" $MILL_FIRST_ARG -D "mill.main.cli=${MILL_MAIN_CLI}" "$@"

0 commit comments

Comments
 (0)