Skip to content

Commit c469e13

Browse files
authored
Bump Mill to 1.1.0-RC4 (#103)
1 parent 62f4846 commit c469e13

File tree

3 files changed

+356
-202
lines changed

3 files changed

+356
-202
lines changed

build.mill

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//| mill-version: 1.0.6
21
//| mvnDeps:
32
//| - com.github.lolgab::mill-mima_mill1:0.2.0
43
package build
@@ -45,6 +44,7 @@ trait MimaCheck extends ScalaModule with Mima {
4544

4645

4746
trait GenyPublishModule extends PublishModule with MimaCheck {
47+
def jvmVersion = "11"
4848
override def artifactName = "geny"
4949

5050
override def publishVersion: T[String] = VcsVersion.vcsState().format()

mill

Lines changed: 55 additions & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,15 @@
11
#!/usr/bin/env sh
22

3-
# This is a wrapper script, that automatically selects or downloads Mill from Maven Central or GitHub release pages.
4-
#
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 fronmatter 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.0-M1-21-7b6fae-DIRTY892b63e8
27-
#
28-
# If you want to improve this script, please also contribute your changes back!
29-
# This script was generated from: dist/scripts/src/mill.sh
30-
#
31-
# Licensed under the Apache License, Version 2.0
32-
333
set -e
344

35-
if [ -z "${DEFAULT_MILL_VERSION}" ] ; then
36-
DEFAULT_MILL_VERSION="0.12.10"
37-
fi
38-
5+
if [ -z "${DEFAULT_MILL_VERSION}" ] ; then DEFAULT_MILL_VERSION="1.1.0-RC4"; fi
396

40-
if [ -z "${GITHUB_RELEASE_CDN}" ] ; then
41-
GITHUB_RELEASE_CDN=""
42-
fi
7+
if [ -z "${GITHUB_RELEASE_CDN}" ] ; then GITHUB_RELEASE_CDN=""; fi
438

9+
if [ -z "$MILL_MAIN_CLI" ] ; then MILL_MAIN_CLI="${0}"; fi
4410

4511
MILL_REPO_URL="https://github.com/com-lihaoyi/mill"
4612

47-
if [ -z "${CURL_CMD}" ] ; then
48-
CURL_CMD=curl
49-
fi
50-
51-
# Explicit commandline argument takes precedence over all other methods
52-
if [ "$1" = "--mill-version" ] ; then
53-
echo "The --mill-version option is no longer supported." 1>&2
54-
fi
55-
5613
MILL_BUILD_SCRIPT=""
5714

5815
if [ -f "build.mill" ] ; then
@@ -63,83 +20,49 @@ elif [ -f "build.sc" ] ; then
6320
MILL_BUILD_SCRIPT="build.sc"
6421
fi
6522

66-
# Please note, that if a MILL_VERSION is already set in the environment,
67-
# We reuse it's value and skip searching for a value.
23+
# `s/.*://`:
24+
# This is a greedy match that removes everything from the beginning of the line up to (and including) the last
25+
# colon (:). This effectively isolates the value part of the declaration.
26+
#
27+
# `s/#.*//`:
28+
# This removes any comments at the end of the line.
29+
#
30+
# `s/['\"]//g`:
31+
# This removes all single and double quotes from the string, wherever they appear (g is for "global").
32+
#
33+
# `s/^[[:space:]]*//; s/[[:space:]]*$//`:
34+
# These two expressions trim any leading or trailing whitespace ([[:space:]] matches spaces and tabs).
35+
TRIM_VALUE_SED="s/.*://; s/#.*//; s/['\"]//g; s/^[[:space:]]*//; s/[[:space:]]*$//"
6836

69-
# If not already set, read .mill-version file
7037
if [ -z "${MILL_VERSION}" ] ; then
7138
if [ -f ".mill-version" ] ; then
7239
MILL_VERSION="$(tr '\r' '\n' < .mill-version | head -n 1 2> /dev/null)"
7340
elif [ -f ".config/mill-version" ] ; then
7441
MILL_VERSION="$(tr '\r' '\n' < .config/mill-version | head -n 1 2> /dev/null)"
42+
elif [ -f "build.mill.yaml" ] ; then
43+
MILL_VERSION="$(grep -E "mill-version:" "build.mill.yaml" | sed -E "$TRIM_VALUE_SED")"
7544
elif [ -n "${MILL_BUILD_SCRIPT}" ] ; then
76-
MILL_VERSION="$(cat ${MILL_BUILD_SCRIPT} | grep '//[|] *mill-version: *' | sed 's;//| *mill-version: *;;')"
45+
MILL_VERSION="$(grep -E "//\|.*mill-version" "${MILL_BUILD_SCRIPT}" | sed -E "$TRIM_VALUE_SED")"
7746
fi
7847
fi
7948

80-
MILL_USER_CACHE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/mill"
81-
82-
if [ -z "${MILL_DOWNLOAD_PATH}" ] ; then
83-
MILL_DOWNLOAD_PATH="${MILL_USER_CACHE_DIR}/download"
84-
fi
85-
86-
# If not already set, try to fetch newest from Github
87-
if [ -z "${MILL_VERSION}" ] ; then
88-
# TODO: try to load latest version from release page
89-
echo "No mill version specified." 1>&2
90-
echo "You should provide a version via a '//| mill-version: ' comment or a '.mill-version' file." 1>&2
91-
92-
mkdir -p "${MILL_DOWNLOAD_PATH}"
93-
LANG=C touch -d '1 hour ago' "${MILL_DOWNLOAD_PATH}/.expire_latest" 2>/dev/null || (
94-
# we might be on OSX or BSD which don't have -d option for touch
95-
# but probably a -A [-][[hh]mm]SS
96-
touch "${MILL_DOWNLOAD_PATH}/.expire_latest"; touch -A -010000 "${MILL_DOWNLOAD_PATH}/.expire_latest"
97-
) || (
98-
# in case we still failed, we retry the first touch command with the intention
99-
# to show the (previously suppressed) error message
100-
LANG=C touch -d '1 hour ago' "${MILL_DOWNLOAD_PATH}/.expire_latest"
101-
)
49+
if [ -z "${MILL_VERSION}" ] ; then MILL_VERSION="${DEFAULT_MILL_VERSION}"; fi
10250

103-
# POSIX shell variant of bash's -nt operator, see https://unix.stackexchange.com/a/449744/6993
104-
# if [ "${MILL_DOWNLOAD_PATH}/.latest" -nt "${MILL_DOWNLOAD_PATH}/.expire_latest" ] ; then
105-
if [ -n "$(find -L "${MILL_DOWNLOAD_PATH}/.latest" -prune -newer "${MILL_DOWNLOAD_PATH}/.expire_latest")" ]; then
106-
# we know a current latest version
107-
MILL_VERSION=$(head -n 1 "${MILL_DOWNLOAD_PATH}"/.latest 2> /dev/null)
108-
fi
51+
MILL_USER_CACHE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/mill"
10952

110-
if [ -z "${MILL_VERSION}" ] ; then
111-
# we don't know a current latest version
112-
echo "Retrieving latest mill version ..." 1>&2
113-
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"
114-
MILL_VERSION=$(head -n 1 "${MILL_DOWNLOAD_PATH}"/.latest 2> /dev/null)
115-
fi
116-
117-
if [ -z "${MILL_VERSION}" ] ; then
118-
# Last resort
119-
MILL_VERSION="${DEFAULT_MILL_VERSION}"
120-
echo "Falling back to hardcoded mill version ${MILL_VERSION}" 1>&2
121-
else
122-
echo "Using mill version ${MILL_VERSION}" 1>&2
123-
fi
124-
fi
53+
if [ -z "${MILL_FINAL_DOWNLOAD_FOLDER}" ] ; then MILL_FINAL_DOWNLOAD_FOLDER="${MILL_USER_CACHE_DIR}/download"; fi
12554

12655
MILL_NATIVE_SUFFIX="-native"
12756
MILL_JVM_SUFFIX="-jvm"
12857
FULL_MILL_VERSION=$MILL_VERSION
12958
ARTIFACT_SUFFIX=""
13059
set_artifact_suffix(){
13160
if [ "$(expr substr $(uname -s) 1 5 2>/dev/null)" = "Linux" ]; then
132-
if [ "$(uname -m)" = "aarch64" ]; then
133-
ARTIFACT_SUFFIX="-native-linux-aarch64"
134-
else
135-
ARTIFACT_SUFFIX="-native-linux-amd64"
136-
fi
61+
if [ "$(uname -m)" = "aarch64" ]; then ARTIFACT_SUFFIX="-native-linux-aarch64"
62+
else ARTIFACT_SUFFIX="-native-linux-amd64"; fi
13763
elif [ "$(uname)" = "Darwin" ]; then
138-
if [ "$(uname -m)" = "arm64" ]; then
139-
ARTIFACT_SUFFIX="-native-mac-aarch64"
140-
else
141-
ARTIFACT_SUFFIX="-native-mac-amd64"
142-
fi
64+
if [ "$(uname -m)" = "arm64" ]; then ARTIFACT_SUFFIX="-native-mac-aarch64"
65+
else ARTIFACT_SUFFIX="-native-mac-amd64"; fi
14366
else
14467
echo "This native mill launcher supports only Linux and macOS." 1>&2
14568
exit 1
@@ -176,136 +99,67 @@ case "$MILL_VERSION" in
17699
;;
177100
esac
178101

179-
MILL="${MILL_DOWNLOAD_PATH}/$MILL_VERSION$ARTIFACT_SUFFIX"
180-
181-
try_to_use_system_mill() {
182-
if [ "$(uname)" != "Linux" ]; then
183-
return 0
184-
fi
185-
186-
MILL_IN_PATH="$(command -v mill || true)"
187-
188-
if [ -z "${MILL_IN_PATH}" ]; then
189-
return 0
190-
fi
191-
192-
SYSTEM_MILL_FIRST_TWO_BYTES=$(head --bytes=2 "${MILL_IN_PATH}")
193-
if [ "${SYSTEM_MILL_FIRST_TWO_BYTES}" = "#!" ]; then
194-
# MILL_IN_PATH is (very likely) a shell script and not the mill
195-
# executable, ignore it.
196-
return 0
197-
fi
198-
199-
SYSTEM_MILL_PATH=$(readlink -e "${MILL_IN_PATH}")
200-
SYSTEM_MILL_SIZE=$(stat --format=%s "${SYSTEM_MILL_PATH}")
201-
SYSTEM_MILL_MTIME=$(stat --format=%y "${SYSTEM_MILL_PATH}")
202-
203-
if [ ! -d "${MILL_USER_CACHE_DIR}" ]; then
204-
mkdir -p "${MILL_USER_CACHE_DIR}"
205-
fi
206-
207-
SYSTEM_MILL_INFO_FILE="${MILL_USER_CACHE_DIR}/system-mill-info"
208-
if [ -f "${SYSTEM_MILL_INFO_FILE}" ]; then
209-
parseSystemMillInfo() {
210-
LINE_NUMBER="${1}"
211-
# Select the line number of the SYSTEM_MILL_INFO_FILE, cut the
212-
# variable definition in that line in two halves and return
213-
# the value, and finally remove the quotes.
214-
sed -n "${LINE_NUMBER}p" "${SYSTEM_MILL_INFO_FILE}" |\
215-
cut -d= -f2 |\
216-
sed 's/"\(.*\)"/\1/'
217-
}
218-
219-
CACHED_SYSTEM_MILL_PATH=$(parseSystemMillInfo 1)
220-
CACHED_SYSTEM_MILL_VERSION=$(parseSystemMillInfo 2)
221-
CACHED_SYSTEM_MILL_SIZE=$(parseSystemMillInfo 3)
222-
CACHED_SYSTEM_MILL_MTIME=$(parseSystemMillInfo 4)
223-
224-
if [ "${SYSTEM_MILL_PATH}" = "${CACHED_SYSTEM_MILL_PATH}" ] \
225-
&& [ "${SYSTEM_MILL_SIZE}" = "${CACHED_SYSTEM_MILL_SIZE}" ] \
226-
&& [ "${SYSTEM_MILL_MTIME}" = "${CACHED_SYSTEM_MILL_MTIME}" ]; then
227-
if [ "${CACHED_SYSTEM_MILL_VERSION}" = "${MILL_VERSION}" ]; then
228-
MILL="${SYSTEM_MILL_PATH}"
229-
return 0
230-
else
231-
return 0
232-
fi
233-
fi
234-
fi
235-
236-
SYSTEM_MILL_VERSION=$(${SYSTEM_MILL_PATH} --version | head -n1 | sed -n 's/^Mill.*version \(.*\)/\1/p')
237-
238-
cat <<EOF > "${SYSTEM_MILL_INFO_FILE}"
239-
CACHED_SYSTEM_MILL_PATH="${SYSTEM_MILL_PATH}"
240-
CACHED_SYSTEM_MILL_VERSION="${SYSTEM_MILL_VERSION}"
241-
CACHED_SYSTEM_MILL_SIZE="${SYSTEM_MILL_SIZE}"
242-
CACHED_SYSTEM_MILL_MTIME="${SYSTEM_MILL_MTIME}"
243-
EOF
244-
245-
if [ "${SYSTEM_MILL_VERSION}" = "${MILL_VERSION}" ]; then
246-
MILL="${SYSTEM_MILL_PATH}"
247-
fi
248-
}
249-
try_to_use_system_mill
102+
MILL="${MILL_FINAL_DOWNLOAD_FOLDER}/$MILL_VERSION$ARTIFACT_SUFFIX"
250103

251104
# If not already downloaded, download it
252105
if [ ! -s "${MILL}" ] || [ "$MILL_TEST_DRY_RUN_LAUNCHER_SCRIPT" = "1" ] ; then
253106
case $MILL_VERSION in
254107
0.0.* | 0.1.* | 0.2.* | 0.3.* | 0.4.* )
255-
DOWNLOAD_SUFFIX=""
256-
DOWNLOAD_FROM_MAVEN=0
108+
MILL_DOWNLOAD_SUFFIX=""
109+
MILL_DOWNLOAD_FROM_MAVEN=0
257110
;;
258111
0.5.* | 0.6.* | 0.7.* | 0.8.* | 0.9.* | 0.10.* | 0.11.0-M* )
259-
DOWNLOAD_SUFFIX="-assembly"
260-
DOWNLOAD_FROM_MAVEN=0
112+
MILL_DOWNLOAD_SUFFIX="-assembly"
113+
MILL_DOWNLOAD_FROM_MAVEN=0
261114
;;
262115
*)
263-
DOWNLOAD_SUFFIX="-assembly"
264-
DOWNLOAD_FROM_MAVEN=1
116+
MILL_DOWNLOAD_SUFFIX="-assembly"
117+
MILL_DOWNLOAD_FROM_MAVEN=1
265118
;;
266119
esac
267120
case $MILL_VERSION in
268121
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 )
269-
DOWNLOAD_EXT="jar"
122+
MILL_DOWNLOAD_EXT="jar"
270123
;;
271124
0.12.* )
272-
DOWNLOAD_EXT="exe"
125+
MILL_DOWNLOAD_EXT="exe"
273126
;;
274127
0.* )
275-
DOWNLOAD_EXT="jar"
128+
MILL_DOWNLOAD_EXT="jar"
276129
;;
277130
*)
278-
DOWNLOAD_EXT="exe"
131+
MILL_DOWNLOAD_EXT="exe"
279132
;;
280133
esac
281134

282-
DOWNLOAD_FILE=$(mktemp mill.XXXXXX)
283-
if [ "$DOWNLOAD_FROM_MAVEN" = "1" ] ; then
284-
DOWNLOAD_URL="https://repo1.maven.org/maven2/com/lihaoyi/mill-dist${ARTIFACT_SUFFIX}/${MILL_VERSION}/mill-dist${ARTIFACT_SUFFIX}-${MILL_VERSION}.${DOWNLOAD_EXT}"
135+
MILL_TEMP_DOWNLOAD_FILE="${MILL_OUTPUT_DIR:-out}/mill-temp-download"
136+
mkdir -p "$(dirname "${MILL_TEMP_DOWNLOAD_FILE}")"
137+
138+
if [ "$MILL_DOWNLOAD_FROM_MAVEN" = "1" ] ; then
139+
MILL_DOWNLOAD_URL="https://repo1.maven.org/maven2/com/lihaoyi/mill-dist${ARTIFACT_SUFFIX}/${MILL_VERSION}/mill-dist${ARTIFACT_SUFFIX}-${MILL_VERSION}.${MILL_DOWNLOAD_EXT}"
285140
else
286141
MILL_VERSION_TAG=$(echo "$MILL_VERSION" | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/')
287-
DOWNLOAD_URL="${GITHUB_RELEASE_CDN}${MILL_REPO_URL}/releases/download/${MILL_VERSION_TAG}/${MILL_VERSION}${DOWNLOAD_SUFFIX}"
142+
MILL_DOWNLOAD_URL="${GITHUB_RELEASE_CDN}${MILL_REPO_URL}/releases/download/${MILL_VERSION_TAG}/${MILL_VERSION}${MILL_DOWNLOAD_SUFFIX}"
288143
unset MILL_VERSION_TAG
289144
fi
290145

146+
291147
if [ "$MILL_TEST_DRY_RUN_LAUNCHER_SCRIPT" = "1" ] ; then
292-
echo $DOWNLOAD_URL
148+
echo $MILL_DOWNLOAD_URL
293149
echo $MILL
294150
exit 0
295151
fi
296-
# TODO: handle command not found
297-
echo "Downloading mill ${MILL_VERSION} from ${DOWNLOAD_URL} ..." 1>&2
298-
${CURL_CMD} -f -L -o "${DOWNLOAD_FILE}" "${DOWNLOAD_URL}"
299-
chmod +x "${DOWNLOAD_FILE}"
300-
mkdir -p "${MILL_DOWNLOAD_PATH}"
301-
mv "${DOWNLOAD_FILE}" "${MILL}"
302152

303-
unset DOWNLOAD_FILE
304-
unset DOWNLOAD_SUFFIX
305-
fi
153+
echo "Downloading mill ${MILL_VERSION} from ${MILL_DOWNLOAD_URL} ..." 1>&2
154+
curl -f -L -o "${MILL_TEMP_DOWNLOAD_FILE}" "${MILL_DOWNLOAD_URL}"
155+
156+
chmod +x "${MILL_TEMP_DOWNLOAD_FILE}"
157+
158+
mkdir -p "${MILL_FINAL_DOWNLOAD_FOLDER}"
159+
mv "${MILL_TEMP_DOWNLOAD_FILE}" "${MILL}"
306160

307-
if [ -z "$MILL_MAIN_CLI" ] ; then
308-
MILL_MAIN_CLI="${0}"
161+
unset MILL_TEMP_DOWNLOAD_FILE
162+
unset MILL_DOWNLOAD_SUFFIX
309163
fi
310164

311165
MILL_FIRST_ARG=""
@@ -315,7 +169,7 @@ if [ "$1" = "--bsp" ] || [ "${1#"-i"}" != "$1" ] || [ "$1" = "--interactive" ] |
315169
shift
316170
fi
317171

318-
unset MILL_DOWNLOAD_PATH
172+
unset MILL_FINAL_DOWNLOAD_FOLDER
319173
unset MILL_OLD_DOWNLOAD_PATH
320174
unset OLD_MILL
321175
unset MILL_VERSION

0 commit comments

Comments
 (0)