From e2941de4387f6bf522b15c876f8e8ddcf050e080 Mon Sep 17 00:00:00 2001 From: Piotr Chabelski Date: Tue, 15 Jul 2025 10:12:48 +0200 Subject: [PATCH 1/3] Update Mill scripts --- mill | 381 ++++++++++++++++++++++++++++------- mill.bat | 598 +++++++++++++++++++++++++++---------------------------- 2 files changed, 611 insertions(+), 368 deletions(-) diff --git a/mill b/mill index 931612bef3..17ceb7f2e9 100755 --- a/mill +++ b/mill @@ -1,90 +1,333 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -# Adapted from +# This is a wrapper script, that automatically selects or downloads Mill from Maven Central or GitHub release pages. +# +# This script determines the Mill version to use by trying these sources +# - env-variable `MILL_VERSION` +# - local file `.mill-version` +# - local file `.config/mill-version` +# - `mill-version` from YAML fronmatter of current buildfile +# - if accessible, find the latest stable version available on Maven Central (https://repo1.maven.org/maven2) +# - env-variable `DEFAULT_MILL_VERSION` +# +# If a version has the suffix '-native' a native binary will be used. +# If a version has the suffix '-jvm' an executable jar file will be used, requiring an already installed Java runtime. +# If no such suffix is found, the script will pick a default based on version and platform. +# +# Once a version was determined, it tries to use either +# - a system-installed mill, if found and it's version matches +# - an already downloaded version under ~/.cache/mill/download +# +# If no working mill version was found on the system, +# this script downloads a binary file from Maven Central or Github Pages (this is version dependent) +# into a cache location (~/.cache/mill/download). +# +# Mill Project URL: https://github.com/com-lihaoyi/mill +# Script Version: 1.0.0-M1-21-7b6fae-DIRTY892b63e8 +# +# If you want to improve this script, please also contribute your changes back! +# This script was generated from: dist/scripts/src/mill.sh +# +# Licensed under the Apache License, Version 2.0 -coursier_version="2.1.24" -COMMAND=$@ +set -e -# necessary for Windows various shell environments -IS_WINDOWS=$(uname | grep -E 'CYG*|MSYS*|MING*|UCRT*|ClANG*|GIT*') +if [ "$1" = "--setup-completions" ] ; then + # Need to preserve the first position of those listed options + MILL_FIRST_ARG=$1 + shift +fi -# 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" +if [ -z "${DEFAULT_MILL_VERSION}" ] ; then + DEFAULT_MILL_VERSION=1.0.0 +fi + + +if [ -z "${GITHUB_RELEASE_CDN}" ] ; then + GITHUB_RELEASE_CDN="" +fi + + +MILL_REPO_URL="https://github.com/com-lihaoyi/mill" + +if [ -z "${CURL_CMD}" ] ; then + CURL_CMD=curl +fi + +# Explicit commandline argument takes precedence over all other methods +if [ "$1" = "--mill-version" ] ; then + echo "The --mill-version option is no longer supported." 1>&2 +fi + +MILL_BUILD_SCRIPT="" + +if [ -f "build.mill" ] ; then + MILL_BUILD_SCRIPT="build.mill" +elif [ -f "build.mill.scala" ] ; then + MILL_BUILD_SCRIPT="build.mill.scala" +elif [ -f "build.sc" ] ; then + MILL_BUILD_SCRIPT="build.sc" +fi + +# Please note, that if a MILL_VERSION is already set in the environment, +# We reuse it's value and skip searching for a value. + +# If not already set, read .mill-version file +if [ -z "${MILL_VERSION}" ] ; then + if [ -f ".mill-version" ] ; then + MILL_VERSION="$(tr '\r' '\n' < .mill-version | head -n 1 2> /dev/null)" + elif [ -f ".config/mill-version" ] ; then + MILL_VERSION="$(tr '\r' '\n' < .config/mill-version | head -n 1 2> /dev/null)" + elif [ -n "${MILL_BUILD_SCRIPT}" ] ; then + MILL_VERSION="$(cat ${MILL_BUILD_SCRIPT} | grep '//[|] *mill-version: *' | sed 's;//| *mill-version: *;;')" 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@://@/@')" +MILL_USER_CACHE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/mill" -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" +if [ -z "${MILL_DOWNLOAD_PATH}" ] ; then + MILL_DOWNLOAD_PATH="${MILL_USER_CACHE_DIR}/download" fi -if [[ "$cache_dest" == *.gz ]]; then - cs="$(dirname "$cache_dest")/$(basename "$cache_dest" .gz)" - if [ ! -f "$cs" ]; then - gzip -d < "$cache_dest" > "$cs" +# If not already set, try to fetch newest from Github +if [ -z "${MILL_VERSION}" ] ; then + # TODO: try to load latest version from release page + echo "No mill version specified." 1>&2 + echo "You should provide a version via a '//| mill-version: ' comment or a '.mill-version' file." 1>&2 + + mkdir -p "${MILL_DOWNLOAD_PATH}" + LANG=C touch -d '1 hour ago' "${MILL_DOWNLOAD_PATH}/.expire_latest" 2>/dev/null || ( + # we might be on OSX or BSD which don't have -d option for touch + # but probably a -A [-][[hh]mm]SS + touch "${MILL_DOWNLOAD_PATH}/.expire_latest"; touch -A -010000 "${MILL_DOWNLOAD_PATH}/.expire_latest" + ) || ( + # in case we still failed, we retry the first touch command with the intention + # to show the (previously suppressed) error message + LANG=C touch -d '1 hour ago' "${MILL_DOWNLOAD_PATH}/.expire_latest" + ) + + # POSIX shell variant of bash's -nt operator, see https://unix.stackexchange.com/a/449744/6993 + # if [ "${MILL_DOWNLOAD_PATH}/.latest" -nt "${MILL_DOWNLOAD_PATH}/.expire_latest" ] ; then + if [ -n "$(find -L "${MILL_DOWNLOAD_PATH}/.latest" -prune -newer "${MILL_DOWNLOAD_PATH}/.expire_latest")" ]; then + # we know a current latest version + MILL_VERSION=$(head -n 1 "${MILL_DOWNLOAD_PATH}"/.latest 2> /dev/null) fi - if [ ! -x "$cs" ]; then - chmod +x "$cs" + + if [ -z "${MILL_VERSION}" ] ; then + # we don't know a current latest version + echo "Retrieving latest mill version ..." 1>&2 + 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" + MILL_VERSION=$(head -n 1 "${MILL_DOWNLOAD_PATH}"/.latest 2> /dev/null) 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" + + if [ -z "${MILL_VERSION}" ] ; then + # Last resort + MILL_VERSION="${DEFAULT_MILL_VERSION}" + echo "Falling back to hardcoded mill version ${MILL_VERSION}" 1>&2 + else + echo "Using mill version ${MILL_VERSION}" 1>&2 fi fi -# If cs is not a valid file, fall back to the `cs` command in PATH -if [ ! -f "$cs" ]; then - cs="$(command -v cs)" -fi +MILL_NATIVE_SUFFIX="-native" +MILL_JVM_SUFFIX="-jvm" +FULL_MILL_VERSION=$MILL_VERSION +ARTIFACT_SUFFIX="" +set_artifact_suffix(){ + if [ "$(expr substr $(uname -s) 1 5 2>/dev/null)" = "Linux" ]; then + if [ "$(uname -m)" = "aarch64" ]; then + ARTIFACT_SUFFIX="-native-linux-aarch64" + else + ARTIFACT_SUFFIX="-native-linux-amd64" + fi + elif [ "$(uname)" = "Darwin" ]; then + if [ "$(uname -m)" = "arm64" ]; then + ARTIFACT_SUFFIX="-native-mac-aarch64" + else + ARTIFACT_SUFFIX="-native-mac-amd64" + fi + else + echo "This native mill launcher supports only Linux and macOS." 1>&2 + exit 1 + fi +} + +case "$MILL_VERSION" in + *"$MILL_NATIVE_SUFFIX") + MILL_VERSION=${MILL_VERSION%"$MILL_NATIVE_SUFFIX"} + set_artifact_suffix + ;; + + *"$MILL_JVM_SUFFIX") + MILL_VERSION=${MILL_VERSION%"$MILL_JVM_SUFFIX"} + ;; + + *) + case "$MILL_VERSION" in + 0.1.*) ;; + 0.2.*) ;; + 0.3.*) ;; + 0.4.*) ;; + 0.5.*) ;; + 0.6.*) ;; + 0.7.*) ;; + 0.8.*) ;; + 0.9.*) ;; + 0.10.*) ;; + 0.11.*) ;; + 0.12.*) ;; + *) + set_artifact_suffix + esac + ;; +esac -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 +MILL="${MILL_DOWNLOAD_PATH}/$MILL_VERSION$ARTIFACT_SUFFIX" + +try_to_use_system_mill() { + if [ "$(uname)" != "Linux" ]; then + return 0 + fi + + MILL_IN_PATH="$(command -v mill || true)" + + if [ -z "${MILL_IN_PATH}" ]; then + return 0 + fi + + SYSTEM_MILL_FIRST_TWO_BYTES=$(head --bytes=2 "${MILL_IN_PATH}") + if [ "${SYSTEM_MILL_FIRST_TWO_BYTES}" = "#!" ]; then + # MILL_IN_PATH is (very likely) a shell script and not the mill + # executable, ignore it. + return 0 + fi + + SYSTEM_MILL_PATH=$(readlink -e "${MILL_IN_PATH}") + SYSTEM_MILL_SIZE=$(stat --format=%s "${SYSTEM_MILL_PATH}") + SYSTEM_MILL_MTIME=$(stat --format=%y "${SYSTEM_MILL_PATH}") + + if [ ! -d "${MILL_USER_CACHE_DIR}" ]; then + mkdir -p "${MILL_USER_CACHE_DIR}" + fi + + SYSTEM_MILL_INFO_FILE="${MILL_USER_CACHE_DIR}/system-mill-info" + if [ -f "${SYSTEM_MILL_INFO_FILE}" ]; then + parseSystemMillInfo() { + LINE_NUMBER="${1}" + # Select the line number of the SYSTEM_MILL_INFO_FILE, cut the + # variable definition in that line in two halves and return + # the value, and finally remove the quotes. + sed -n "${LINE_NUMBER}p" "${SYSTEM_MILL_INFO_FILE}" |\ + cut -d= -f2 |\ + sed 's/"\(.*\)"/\1/' + } + + CACHED_SYSTEM_MILL_PATH=$(parseSystemMillInfo 1) + CACHED_SYSTEM_MILL_VERSION=$(parseSystemMillInfo 2) + CACHED_SYSTEM_MILL_SIZE=$(parseSystemMillInfo 3) + CACHED_SYSTEM_MILL_MTIME=$(parseSystemMillInfo 4) + + if [ "${SYSTEM_MILL_PATH}" = "${CACHED_SYSTEM_MILL_PATH}" ] \ + && [ "${SYSTEM_MILL_SIZE}" = "${CACHED_SYSTEM_MILL_SIZE}" ] \ + && [ "${SYSTEM_MILL_MTIME}" = "${CACHED_SYSTEM_MILL_MTIME}" ]; then + if [ "${CACHED_SYSTEM_MILL_VERSION}" = "${MILL_VERSION}" ]; then + MILL="${SYSTEM_MILL_PATH}" + return 0 + else + return 0 + fi + fi + fi + + SYSTEM_MILL_VERSION=$(${SYSTEM_MILL_PATH} --version | head -n1 | sed -n 's/^Mill.*version \(.*\)/\1/p') + + cat < "${SYSTEM_MILL_INFO_FILE}" +CACHED_SYSTEM_MILL_PATH="${SYSTEM_MILL_PATH}" +CACHED_SYSTEM_MILL_VERSION="${SYSTEM_MILL_VERSION}" +CACHED_SYSTEM_MILL_SIZE="${SYSTEM_MILL_SIZE}" +CACHED_SYSTEM_MILL_MTIME="${SYSTEM_MILL_MTIME}" +EOF + + if [ "${SYSTEM_MILL_VERSION}" = "${MILL_VERSION}" ]; then + MILL="${SYSTEM_MILL_PATH}" + fi } -if [[ $IS_WINDOWS ]]; 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 +try_to_use_system_mill + +# If not already downloaded, download it +if [ ! -s "${MILL}" ] || [ "$MILL_TEST_DRY_RUN_LAUNCHER_SCRIPT" = "1" ] ; then + case $MILL_VERSION in + 0.0.* | 0.1.* | 0.2.* | 0.3.* | 0.4.* ) + DOWNLOAD_SUFFIX="" + DOWNLOAD_FROM_MAVEN=0 + ;; + 0.5.* | 0.6.* | 0.7.* | 0.8.* | 0.9.* | 0.10.* | 0.11.0-M* ) + DOWNLOAD_SUFFIX="-assembly" + DOWNLOAD_FROM_MAVEN=0 + ;; + *) + DOWNLOAD_SUFFIX="-assembly" + DOWNLOAD_FROM_MAVEN=1 + ;; + esac + case $MILL_VERSION in + 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 ) + DOWNLOAD_EXT="jar" + ;; + 0.12.* ) + DOWNLOAD_EXT="exe" + ;; + 0.* ) + DOWNLOAD_EXT="jar" + ;; + *) + DOWNLOAD_EXT="exe" + ;; + esac + + DOWNLOAD_FILE=$(mktemp mill.XXXXXX) + if [ "$DOWNLOAD_FROM_MAVEN" = "1" ] ; then + DOWNLOAD_URL="https://repo1.maven.org/maven2/com/lihaoyi/mill-dist${ARTIFACT_SUFFIX}/${MILL_VERSION}/mill-dist${ARTIFACT_SUFFIX}-${MILL_VERSION}.${DOWNLOAD_EXT}" + else + MILL_VERSION_TAG=$(echo "$MILL_VERSION" | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/') + DOWNLOAD_URL="${GITHUB_RELEASE_CDN}${MILL_REPO_URL}/releases/download/${MILL_VERSION_TAG}/${MILL_VERSION}${DOWNLOAD_SUFFIX}" + unset MILL_VERSION_TAG + 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 + if [ "$MILL_TEST_DRY_RUN_LAUNCHER_SCRIPT" = "1" ] ; then + echo $DOWNLOAD_URL + echo $MILL + exit 0 + fi + # TODO: handle command not found + echo "Downloading mill ${MILL_VERSION} from ${DOWNLOAD_URL} ..." 1>&2 + ${CURL_CMD} -f -L -o "${DOWNLOAD_FILE}" "${DOWNLOAD_URL}" + chmod +x "${DOWNLOAD_FILE}" + mkdir -p "${MILL_DOWNLOAD_PATH}" + mv "${DOWNLOAD_FILE}" "${MILL}" -DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" + unset DOWNLOAD_FILE + unset DOWNLOAD_SUFFIX +fi -if [[ $IS_WINDOWS ]]; then - exec "$DIR/millw" "$@" -else - exec "$DIR/millw" $COMMAND +if [ -z "$MILL_MAIN_CLI" ] ; then + MILL_MAIN_CLI="${0}" fi + +MILL_FIRST_ARG="" +if [ "$1" = "--bsp" ] || [ "${1#"-i"}" != "$1" ] || [ "$1" = "--interactive" ] || [ "$1" = "--no-server" ] || [ "$1" = "--no-daemon" ] || [ "$1" = "--repl" ] || [ "$1" = "--help" ] ; then + # Need to preserve the first position of those listed options + MILL_FIRST_ARG=$1 + shift +fi + +unset MILL_DOWNLOAD_PATH +unset MILL_OLD_DOWNLOAD_PATH +unset OLD_MILL +unset MILL_VERSION +unset MILL_REPO_URL + +# -D mill.main.cli is for compatibility with Mill 0.10.9 - 0.13.0-M2 +# We don't quote MILL_FIRST_ARG on purpose, so we can expand the empty value without quotes +# shellcheck disable=SC2086 +exec "${MILL}" $MILL_FIRST_ARG -D "mill.main.cli=${MILL_MAIN_CLI}" "$@" diff --git a/mill.bat b/mill.bat index 0d7e1e19fd..a947595a25 100755 --- a/mill.bat +++ b/mill.bat @@ -1,299 +1,299 @@ -@echo off - -rem This is a wrapper script, that automatically selects or downloads Mill from Maven Central or GitHub release pages. -rem -rem This script determines the Mill version to use by trying these sources -rem - env-variable `MILL_VERSION` -rem - local file `.mill-version` -rem - local file `.config/mill-version` -rem - `mill-version` from YAML fronmatter of current buildfile -rem - if accessible, find the latest stable version available on Maven Central (https://repo1.maven.org/maven2) -rem - env-variable `DEFAULT_MILL_VERSION` -rem -rem If a version has the suffix '-native' a native binary will be used. -rem If a version has the suffix '-jvm' an executable jar file will be used, requiring an already installed Java runtime. -rem If no such suffix is found, the script will pick a default based on version and platform. -rem -rem Once a version was determined, it tries to use either -rem - a system-installed mill, if found and it's version matches -rem - an already downloaded version under %USERPROFILE%\.mill\download -rem -rem If no working mill version was found on the system, -rem this script downloads a binary file from Maven Central or Github Pages (this is version dependent) -rem into a cache location (%USERPROFILE%\.mill\download). -rem -rem Mill Project URL: https://github.com/com-lihaoyi/mill -rem Script Version: 1.0.0-M1-21-7b6fae-DIRTY892b63e8 -rem -rem If you want to improve this script, please also contribute your changes back! -rem This script was generated from: dist/scripts/src/mill.bat -rem -rem Licensed under the Apache License, Version 2.0 - -rem setlocal seems to be unavailable on Windows 95/98/ME -rem but I don't think we need to support them in 2019 -setlocal enabledelayedexpansion - -if [!DEFAULT_MILL_VERSION!]==[] ( set "DEFAULT_MILL_VERSION=0.12.14" ) - -if [!MILL_GITHUB_RELEASE_CDN!]==[] ( set "MILL_GITHUB_RELEASE_CDN=" ) - -if [!MILL_MAIN_CLI!]==[] ( set "MILL_MAIN_CLI=%~f0" ) - -set "MILL_REPO_URL=https://github.com/com-lihaoyi/mill" - -SET MILL_BUILD_SCRIPT= - -if exist "build.mill" ( - set MILL_BUILD_SCRIPT=build.mill -) else ( - if exist "build.mill.scala" ( - set MILL_BUILD_SCRIPT=build.mill.scala - ) else ( - if exist "build.sc" ( - set MILL_BUILD_SCRIPT=build.sc - ) else ( - rem no-op - ) - ) -) - -if [!MILL_VERSION!]==[] ( - if exist .mill-version ( - set /p MILL_VERSION=<.mill-version - ) else ( - if exist .config\mill-version ( - set /p MILL_VERSION=<.config\mill-version - ) else ( - if not "%MILL_BUILD_SCRIPT%"=="" ( - for /f "tokens=1-2*" %%a in ('findstr /C:"//| mill-version:" %MILL_BUILD_SCRIPT%') do ( - set "MILL_VERSION=%%c" - ) - ) else ( - rem no-op - ) - ) - ) -) - -if [!MILL_VERSION!]==[] set MILL_VERSION=%DEFAULT_MILL_VERSION% - -if [!MILL_DOWNLOAD_PATH!]==[] set MILL_DOWNLOAD_PATH=%USERPROFILE%\.mill\download - -rem without bat file extension, cmd doesn't seem to be able to run it - -set "MILL_NATIVE_SUFFIX=-native" -set "MILL_JVM_SUFFIX=-jvm" -set "FULL_MILL_VERSION=%MILL_VERSION%" -set "MILL_EXT=.bat" -set "ARTIFACT_SUFFIX=" -REM Check if MILL_VERSION contains MILL_NATIVE_SUFFIX -echo !MILL_VERSION! | findstr /C:"%MILL_NATIVE_SUFFIX%" >nul -if !errorlevel! equ 0 ( - set "MILL_VERSION=%MILL_VERSION:-native=%" - REM -native images compiled with graal do not support windows-arm - REM https://github.com/oracle/graal/issues/9215 - IF /I NOT "%PROCESSOR_ARCHITECTURE%"=="ARM64" ( - set "ARTIFACT_SUFFIX=-native-windows-amd64" - set "MILL_EXT=.exe" - ) else ( - rem no-op - ) -) else ( - echo !MILL_VERSION! | findstr /C:"%MILL_JVM_SUFFIX%" >nul - if !errorlevel! equ 0 ( - set "MILL_VERSION=%MILL_VERSION:-jvm=%" - ) else ( - set "SKIP_VERSION=false" - set "MILL_PREFIX=%MILL_VERSION:~0,4%" - if "!MILL_PREFIX!"=="0.1." set "SKIP_VERSION=true" - if "!MILL_PREFIX!"=="0.2." set "SKIP_VERSION=true" - if "!MILL_PREFIX!"=="0.3." set "SKIP_VERSION=true" - if "!MILL_PREFIX!"=="0.4." set "SKIP_VERSION=true" - if "!MILL_PREFIX!"=="0.5." set "SKIP_VERSION=true" - if "!MILL_PREFIX!"=="0.6." set "SKIP_VERSION=true" - if "!MILL_PREFIX!"=="0.7." set "SKIP_VERSION=true" - if "!MILL_PREFIX!"=="0.8." set "SKIP_VERSION=true" - if "!MILL_PREFIX!"=="0.9." set "SKIP_VERSION=true" - set "MILL_PREFIX=%MILL_VERSION:~0,5%" - if "!MILL_PREFIX!"=="0.10." set "SKIP_VERSION=true" - if "!MILL_PREFIX!"=="0.11." set "SKIP_VERSION=true" - if "!MILL_PREFIX!"=="0.12." set "SKIP_VERSION=true" - - if "!SKIP_VERSION!"=="false" ( - IF /I NOT "%PROCESSOR_ARCHITECTURE%"=="ARM64" ( - set "ARTIFACT_SUFFIX=-native-windows-amd64" - set "MILL_EXT=.exe" - ) - ) else ( - rem no-op - ) - ) -) - -set MILL=%MILL_DOWNLOAD_PATH%\!FULL_MILL_VERSION!!MILL_EXT! - -set MILL_RESOLVE_DOWNLOAD= - -if not exist "%MILL%" ( - set MILL_RESOLVE_DOWNLOAD=true -) else ( - if defined MILL_TEST_DRY_RUN_LAUNCHER_SCRIPT ( - set MILL_RESOLVE_DOWNLOAD=true - ) else ( - rem no-op - ) -) - - -if [!MILL_RESOLVE_DOWNLOAD!]==[true] ( - set MILL_VERSION_PREFIX=%MILL_VERSION:~0,4% - set MILL_SHORT_VERSION_PREFIX=%MILL_VERSION:~0,2% - rem Since 0.5.0 - set MILL_DOWNLOAD_SUFFIX=-assembly - rem Since 0.11.0 - set MILL_DOWNLOAD_FROM_MAVEN=1 - if [!MILL_VERSION_PREFIX!]==[0.0.] ( - set MILL_DOWNLOAD_SUFFIX= - set MILL_DOWNLOAD_FROM_MAVEN=0 - ) - if [!MILL_VERSION_PREFIX!]==[0.1.] ( - set MILL_DOWNLOAD_SUFFIX= - set MILL_DOWNLOAD_FROM_MAVEN=0 - ) - if [!MILL_VERSION_PREFIX!]==[0.2.] ( - set MILL_DOWNLOAD_SUFFIX= - set MILL_DOWNLOAD_FROM_MAVEN=0 - ) - if [!MILL_VERSION_PREFIX!]==[0.3.] ( - set MILL_DOWNLOAD_SUFFIX= - set MILL_DOWNLOAD_FROM_MAVEN=0 - ) - if [!MILL_VERSION_PREFIX!]==[0.4.] ( - set MILL_DOWNLOAD_SUFFIX= - set MILL_DOWNLOAD_FROM_MAVEN=0 - ) - if [!MILL_VERSION_PREFIX!]==[0.5.] set MILL_DOWNLOAD_FROM_MAVEN=0 - if [!MILL_VERSION_PREFIX!]==[0.6.] set MILL_DOWNLOAD_FROM_MAVEN=0 - if [!MILL_VERSION_PREFIX!]==[0.7.] set MILL_DOWNLOAD_FROM_MAVEN=0 - if [!MILL_VERSION_PREFIX!]==[0.8.] set MILL_DOWNLOAD_FROM_MAVEN=0 - if [!MILL_VERSION_PREFIX!]==[0.9.] set MILL_DOWNLOAD_FROM_MAVEN=0 - - set MILL_VERSION_PREFIX=%MILL_VERSION:~0,5% - if [!MILL_VERSION_PREFIX!]==[0.10.] set MILL_DOWNLOAD_FROM_MAVEN=0 - - set MILL_VERSION_PREFIX=%MILL_VERSION:~0,8% - if [!MILL_VERSION_PREFIX!]==[0.11.0-M] set MILL_DOWNLOAD_FROM_MAVEN=0 - - set MILL_VERSION_PREFIX=%MILL_VERSION:~0,5% - set DOWNLOAD_EXT=exe - if [!MILL_SHORT_VERSION_PREFIX!]==[0.] set DOWNLOAD_EXT=jar - if [!MILL_VERSION_PREFIX!]==[0.12.] set DOWNLOAD_EXT=exe - if [!MILL_VERSION!]==[0.12.0] set DOWNLOAD_EXT=jar - if [!MILL_VERSION!]==[0.12.1] set DOWNLOAD_EXT=jar - if [!MILL_VERSION!]==[0.12.2] set DOWNLOAD_EXT=jar - if [!MILL_VERSION!]==[0.12.3] set DOWNLOAD_EXT=jar - if [!MILL_VERSION!]==[0.12.4] set DOWNLOAD_EXT=jar - if [!MILL_VERSION!]==[0.12.5] set DOWNLOAD_EXT=jar - if [!MILL_VERSION!]==[0.12.6] set DOWNLOAD_EXT=jar - if [!MILL_VERSION!]==[0.12.7] set DOWNLOAD_EXT=jar - if [!MILL_VERSION!]==[0.12.8] set DOWNLOAD_EXT=jar - if [!MILL_VERSION!]==[0.12.9] set DOWNLOAD_EXT=jar - if [!MILL_VERSION!]==[0.12.10] set DOWNLOAD_EXT=jar - if [!MILL_VERSION!]==[0.12.11] set DOWNLOAD_EXT=jar - - set MILL_VERSION_PREFIX= - set MILL_SHORT_VERSION_PREFIX= - - for /F "delims=- tokens=1" %%A in ("!MILL_VERSION!") do set MILL_VERSION_BASE=%%A - set MILL_VERSION_MILESTONE= - for /F "delims=- tokens=2" %%A in ("!MILL_VERSION!") do set MILL_VERSION_MILESTONE=%%A - set MILL_VERSION_MILESTONE_START=!MILL_VERSION_MILESTONE:~0,1! - if [!MILL_VERSION_MILESTONE_START!]==[M] ( - set MILL_VERSION_TAG=!MILL_VERSION_BASE!-!MILL_VERSION_MILESTONE! - ) else ( - set MILL_VERSION_TAG=!MILL_VERSION_BASE! - ) - if [!MILL_DOWNLOAD_FROM_MAVEN!]==[1] ( - set MILL_DOWNLOAD_URL=https://repo1.maven.org/maven2/com/lihaoyi/mill-dist!ARTIFACT_SUFFIX!/!MILL_VERSION!/mill-dist!ARTIFACT_SUFFIX!-!MILL_VERSION!.!DOWNLOAD_EXT! - ) else ( - set MILL_DOWNLOAD_URL=!MILL_GITHUB_RELEASE_CDN!%MILL_REPO_URL%/releases/download/!MILL_VERSION_TAG!/!MILL_VERSION!!MILL_DOWNLOAD_SUFFIX! - ) - - if defined MILL_TEST_DRY_RUN_LAUNCHER_SCRIPT ( - echo !MILL_DOWNLOAD_URL! - echo !MILL! - exit /b 0 - ) - - rem there seems to be no way to generate a unique temporary file path (on native Windows) - set MILL_DOWNLOAD_FILE=%MILL%.tmp - - echo Downloading mill !MILL_VERSION! from !MILL_DOWNLOAD_URL! ... 1>&2 - - if not exist "%MILL_DOWNLOAD_PATH%" mkdir "%MILL_DOWNLOAD_PATH%" - rem curl is bundled with recent Windows 10 - rem but I don't think we can expect all the users to have it in 2019 - where /Q curl - if !ERRORLEVEL! EQU 0 ( - curl -f -L "!MILL_DOWNLOAD_URL!" -o "!MILL_DOWNLOAD_FILE!" - ) else ( - rem bitsadmin seems to be available on Windows 7 - rem without /dynamic, github returns 403 - rem bitsadmin is sometimes needlessly slow but it looks better with /priority foreground - bitsadmin /transfer millDownloadJob /dynamic /priority foreground "!MILL_DOWNLOAD_URL!" "!MILL_DOWNLOAD_FILE!" - ) - if not exist "!MILL_DOWNLOAD_FILE!" ( - echo Could not download mill !MILL_VERSION! 1>&2 - exit /b 1 - ) - - move /y "!MILL_DOWNLOAD_FILE!" "%MILL%" - - set MILL_DOWNLOAD_FILE= - set MILL_DOWNLOAD_SUFFIX= -) - -set MILL_DOWNLOAD_PATH= -set MILL_VERSION= -set MILL_REPO_URL= - -rem Need to preserve the first position of those listed options -set MILL_FIRST_ARG= -if [%~1%]==[--bsp] ( - set MILL_FIRST_ARG=%1% -) else ( - if [%~1%]==[-i] ( - set MILL_FIRST_ARG=%1% - ) else ( - if [%~1%]==[--interactive] ( - set MILL_FIRST_ARG=%1% - ) else ( - if [%~1%]==[--no-server] ( - set MILL_FIRST_ARG=%1% - ) else ( - if [%~1%]==[--no-daemon] ( - set MILL_FIRST_ARG=%1% - ) else ( - if [%~1%]==[--repl] ( - set MILL_FIRST_ARG=%1% - ) else ( - if [%~1%]==[--help] ( - set MILL_FIRST_ARG=%1% - ) - ) - ) - ) - ) - ) -) -set "MILL_PARAMS=%*%" - -if not [!MILL_FIRST_ARG!]==[] ( - for /f "tokens=1*" %%a in ("%*") do ( - set "MILL_PARAMS=%%b" - ) -) - -rem -D mill.main.cli is for compatibility with Mill 0.10.9 - 0.13.0-M2 -"%MILL%" %MILL_FIRST_ARG% -D "mill.main.cli=%MILL_MAIN_CLI%" %MILL_PARAMS% \ No newline at end of file +@echo off + +rem This is a wrapper script, that automatically selects or downloads Mill from Maven Central or GitHub release pages. +rem +rem This script determines the Mill version to use by trying these sources +rem - env-variable `MILL_VERSION` +rem - local file `.mill-version` +rem - local file `.config/mill-version` +rem - `mill-version` from YAML fronmatter of current buildfile +rem - if accessible, find the latest stable version available on Maven Central (https://repo1.maven.org/maven2) +rem - env-variable `DEFAULT_MILL_VERSION` +rem +rem If a version has the suffix '-native' a native binary will be used. +rem If a version has the suffix '-jvm' an executable jar file will be used, requiring an already installed Java runtime. +rem If no such suffix is found, the script will pick a default based on version and platform. +rem +rem Once a version was determined, it tries to use either +rem - a system-installed mill, if found and it's version matches +rem - an already downloaded version under %USERPROFILE%\.mill\download +rem +rem If no working mill version was found on the system, +rem this script downloads a binary file from Maven Central or Github Pages (this is version dependent) +rem into a cache location (%USERPROFILE%\.mill\download). +rem +rem Mill Project URL: https://github.com/com-lihaoyi/mill +rem Script Version: 1.0.0-M1-21-7b6fae-DIRTY892b63e8 +rem +rem If you want to improve this script, please also contribute your changes back! +rem This script was generated from: dist/scripts/src/mill.bat +rem +rem Licensed under the Apache License, Version 2.0 + +rem setlocal seems to be unavailable on Windows 95/98/ME +rem but I don't think we need to support them in 2019 +setlocal enabledelayedexpansion + +if [!DEFAULT_MILL_VERSION!]==[] ( set "DEFAULT_MILL_VERSION=1.0.0" ) + +if [!MILL_GITHUB_RELEASE_CDN!]==[] ( set "MILL_GITHUB_RELEASE_CDN=" ) + +if [!MILL_MAIN_CLI!]==[] ( set "MILL_MAIN_CLI=%~f0" ) + +set "MILL_REPO_URL=https://github.com/com-lihaoyi/mill" + +SET MILL_BUILD_SCRIPT= + +if exist "build.mill" ( + set MILL_BUILD_SCRIPT=build.mill +) else ( + if exist "build.mill.scala" ( + set MILL_BUILD_SCRIPT=build.mill.scala + ) else ( + if exist "build.sc" ( + set MILL_BUILD_SCRIPT=build.sc + ) else ( + rem no-op + ) + ) +) + +if [!MILL_VERSION!]==[] ( + if exist .mill-version ( + set /p MILL_VERSION=<.mill-version + ) else ( + if exist .config\mill-version ( + set /p MILL_VERSION=<.config\mill-version + ) else ( + if not "%MILL_BUILD_SCRIPT%"=="" ( + for /f "tokens=1-2*" %%a in ('findstr /C:"//| mill-version:" %MILL_BUILD_SCRIPT%') do ( + set "MILL_VERSION=%%c" + ) + ) else ( + rem no-op + ) + ) + ) +) + +if [!MILL_VERSION!]==[] set MILL_VERSION=%DEFAULT_MILL_VERSION% + +if [!MILL_DOWNLOAD_PATH!]==[] set MILL_DOWNLOAD_PATH=%USERPROFILE%\.mill\download + +rem without bat file extension, cmd doesn't seem to be able to run it + +set "MILL_NATIVE_SUFFIX=-native" +set "MILL_JVM_SUFFIX=-jvm" +set "FULL_MILL_VERSION=%MILL_VERSION%" +set "MILL_EXT=.bat" +set "ARTIFACT_SUFFIX=" +REM Check if MILL_VERSION contains MILL_NATIVE_SUFFIX +echo !MILL_VERSION! | findstr /C:"%MILL_NATIVE_SUFFIX%" >nul +if !errorlevel! equ 0 ( + set "MILL_VERSION=%MILL_VERSION:-native=%" + REM -native images compiled with graal do not support windows-arm + REM https://github.com/oracle/graal/issues/9215 + IF /I NOT "%PROCESSOR_ARCHITECTURE%"=="ARM64" ( + set "ARTIFACT_SUFFIX=-native-windows-amd64" + set "MILL_EXT=.exe" + ) else ( + rem no-op + ) +) else ( + echo !MILL_VERSION! | findstr /C:"%MILL_JVM_SUFFIX%" >nul + if !errorlevel! equ 0 ( + set "MILL_VERSION=%MILL_VERSION:-jvm=%" + ) else ( + set "SKIP_VERSION=false" + set "MILL_PREFIX=%MILL_VERSION:~0,4%" + if "!MILL_PREFIX!"=="0.1." set "SKIP_VERSION=true" + if "!MILL_PREFIX!"=="0.2." set "SKIP_VERSION=true" + if "!MILL_PREFIX!"=="0.3." set "SKIP_VERSION=true" + if "!MILL_PREFIX!"=="0.4." set "SKIP_VERSION=true" + if "!MILL_PREFIX!"=="0.5." set "SKIP_VERSION=true" + if "!MILL_PREFIX!"=="0.6." set "SKIP_VERSION=true" + if "!MILL_PREFIX!"=="0.7." set "SKIP_VERSION=true" + if "!MILL_PREFIX!"=="0.8." set "SKIP_VERSION=true" + if "!MILL_PREFIX!"=="0.9." set "SKIP_VERSION=true" + set "MILL_PREFIX=%MILL_VERSION:~0,5%" + if "!MILL_PREFIX!"=="0.10." set "SKIP_VERSION=true" + if "!MILL_PREFIX!"=="0.11." set "SKIP_VERSION=true" + if "!MILL_PREFIX!"=="0.12." set "SKIP_VERSION=true" + + if "!SKIP_VERSION!"=="false" ( + IF /I NOT "%PROCESSOR_ARCHITECTURE%"=="ARM64" ( + set "ARTIFACT_SUFFIX=-native-windows-amd64" + set "MILL_EXT=.exe" + ) + ) else ( + rem no-op + ) + ) +) + +set MILL=%MILL_DOWNLOAD_PATH%\!FULL_MILL_VERSION!!MILL_EXT! + +set MILL_RESOLVE_DOWNLOAD= + +if not exist "%MILL%" ( + set MILL_RESOLVE_DOWNLOAD=true +) else ( + if defined MILL_TEST_DRY_RUN_LAUNCHER_SCRIPT ( + set MILL_RESOLVE_DOWNLOAD=true + ) else ( + rem no-op + ) +) + + +if [!MILL_RESOLVE_DOWNLOAD!]==[true] ( + set MILL_VERSION_PREFIX=%MILL_VERSION:~0,4% + set MILL_SHORT_VERSION_PREFIX=%MILL_VERSION:~0,2% + rem Since 0.5.0 + set MILL_DOWNLOAD_SUFFIX=-assembly + rem Since 0.11.0 + set MILL_DOWNLOAD_FROM_MAVEN=1 + if [!MILL_VERSION_PREFIX!]==[0.0.] ( + set MILL_DOWNLOAD_SUFFIX= + set MILL_DOWNLOAD_FROM_MAVEN=0 + ) + if [!MILL_VERSION_PREFIX!]==[0.1.] ( + set MILL_DOWNLOAD_SUFFIX= + set MILL_DOWNLOAD_FROM_MAVEN=0 + ) + if [!MILL_VERSION_PREFIX!]==[0.2.] ( + set MILL_DOWNLOAD_SUFFIX= + set MILL_DOWNLOAD_FROM_MAVEN=0 + ) + if [!MILL_VERSION_PREFIX!]==[0.3.] ( + set MILL_DOWNLOAD_SUFFIX= + set MILL_DOWNLOAD_FROM_MAVEN=0 + ) + if [!MILL_VERSION_PREFIX!]==[0.4.] ( + set MILL_DOWNLOAD_SUFFIX= + set MILL_DOWNLOAD_FROM_MAVEN=0 + ) + if [!MILL_VERSION_PREFIX!]==[0.5.] set MILL_DOWNLOAD_FROM_MAVEN=0 + if [!MILL_VERSION_PREFIX!]==[0.6.] set MILL_DOWNLOAD_FROM_MAVEN=0 + if [!MILL_VERSION_PREFIX!]==[0.7.] set MILL_DOWNLOAD_FROM_MAVEN=0 + if [!MILL_VERSION_PREFIX!]==[0.8.] set MILL_DOWNLOAD_FROM_MAVEN=0 + if [!MILL_VERSION_PREFIX!]==[0.9.] set MILL_DOWNLOAD_FROM_MAVEN=0 + + set MILL_VERSION_PREFIX=%MILL_VERSION:~0,5% + if [!MILL_VERSION_PREFIX!]==[0.10.] set MILL_DOWNLOAD_FROM_MAVEN=0 + + set MILL_VERSION_PREFIX=%MILL_VERSION:~0,8% + if [!MILL_VERSION_PREFIX!]==[0.11.0-M] set MILL_DOWNLOAD_FROM_MAVEN=0 + + set MILL_VERSION_PREFIX=%MILL_VERSION:~0,5% + set DOWNLOAD_EXT=exe + if [!MILL_SHORT_VERSION_PREFIX!]==[0.] set DOWNLOAD_EXT=jar + if [!MILL_VERSION_PREFIX!]==[0.12.] set DOWNLOAD_EXT=exe + if [!MILL_VERSION!]==[0.12.0] set DOWNLOAD_EXT=jar + if [!MILL_VERSION!]==[0.12.1] set DOWNLOAD_EXT=jar + if [!MILL_VERSION!]==[0.12.2] set DOWNLOAD_EXT=jar + if [!MILL_VERSION!]==[0.12.3] set DOWNLOAD_EXT=jar + if [!MILL_VERSION!]==[0.12.4] set DOWNLOAD_EXT=jar + if [!MILL_VERSION!]==[0.12.5] set DOWNLOAD_EXT=jar + if [!MILL_VERSION!]==[0.12.6] set DOWNLOAD_EXT=jar + if [!MILL_VERSION!]==[0.12.7] set DOWNLOAD_EXT=jar + if [!MILL_VERSION!]==[0.12.8] set DOWNLOAD_EXT=jar + if [!MILL_VERSION!]==[0.12.9] set DOWNLOAD_EXT=jar + if [!MILL_VERSION!]==[0.12.10] set DOWNLOAD_EXT=jar + if [!MILL_VERSION!]==[0.12.11] set DOWNLOAD_EXT=jar + + set MILL_VERSION_PREFIX= + set MILL_SHORT_VERSION_PREFIX= + + for /F "delims=- tokens=1" %%A in ("!MILL_VERSION!") do set MILL_VERSION_BASE=%%A + set MILL_VERSION_MILESTONE= + for /F "delims=- tokens=2" %%A in ("!MILL_VERSION!") do set MILL_VERSION_MILESTONE=%%A + set MILL_VERSION_MILESTONE_START=!MILL_VERSION_MILESTONE:~0,1! + if [!MILL_VERSION_MILESTONE_START!]==[M] ( + set MILL_VERSION_TAG=!MILL_VERSION_BASE!-!MILL_VERSION_MILESTONE! + ) else ( + set MILL_VERSION_TAG=!MILL_VERSION_BASE! + ) + if [!MILL_DOWNLOAD_FROM_MAVEN!]==[1] ( + set MILL_DOWNLOAD_URL=https://repo1.maven.org/maven2/com/lihaoyi/mill-dist!ARTIFACT_SUFFIX!/!MILL_VERSION!/mill-dist!ARTIFACT_SUFFIX!-!MILL_VERSION!.!DOWNLOAD_EXT! + ) else ( + set MILL_DOWNLOAD_URL=!MILL_GITHUB_RELEASE_CDN!%MILL_REPO_URL%/releases/download/!MILL_VERSION_TAG!/!MILL_VERSION!!MILL_DOWNLOAD_SUFFIX! + ) + + if defined MILL_TEST_DRY_RUN_LAUNCHER_SCRIPT ( + echo !MILL_DOWNLOAD_URL! + echo !MILL! + exit /b 0 + ) + + rem there seems to be no way to generate a unique temporary file path (on native Windows) + set MILL_DOWNLOAD_FILE=%MILL%.tmp + + echo Downloading mill !MILL_VERSION! from !MILL_DOWNLOAD_URL! ... 1>&2 + + if not exist "%MILL_DOWNLOAD_PATH%" mkdir "%MILL_DOWNLOAD_PATH%" + rem curl is bundled with recent Windows 10 + rem but I don't think we can expect all the users to have it in 2019 + where /Q curl + if !ERRORLEVEL! EQU 0 ( + curl -f -L "!MILL_DOWNLOAD_URL!" -o "!MILL_DOWNLOAD_FILE!" + ) else ( + rem bitsadmin seems to be available on Windows 7 + rem without /dynamic, github returns 403 + rem bitsadmin is sometimes needlessly slow but it looks better with /priority foreground + bitsadmin /transfer millDownloadJob /dynamic /priority foreground "!MILL_DOWNLOAD_URL!" "!MILL_DOWNLOAD_FILE!" + ) + if not exist "!MILL_DOWNLOAD_FILE!" ( + echo Could not download mill !MILL_VERSION! 1>&2 + exit /b 1 + ) + + move /y "!MILL_DOWNLOAD_FILE!" "%MILL%" + + set MILL_DOWNLOAD_FILE= + set MILL_DOWNLOAD_SUFFIX= +) + +set MILL_DOWNLOAD_PATH= +set MILL_VERSION= +set MILL_REPO_URL= + +rem Need to preserve the first position of those listed options +set MILL_FIRST_ARG= +if [%~1%]==[--bsp] ( + set MILL_FIRST_ARG=%1% +) else ( + if [%~1%]==[-i] ( + set MILL_FIRST_ARG=%1% + ) else ( + if [%~1%]==[--interactive] ( + set MILL_FIRST_ARG=%1% + ) else ( + if [%~1%]==[--no-server] ( + set MILL_FIRST_ARG=%1% + ) else ( + if [%~1%]==[--no-daemon] ( + set MILL_FIRST_ARG=%1% + ) else ( + if [%~1%]==[--repl] ( + set MILL_FIRST_ARG=%1% + ) else ( + if [%~1%]==[--help] ( + set MILL_FIRST_ARG=%1% + ) + ) + ) + ) + ) + ) +) +set "MILL_PARAMS=%*%" + +if not [!MILL_FIRST_ARG!]==[] ( + for /f "tokens=1*" %%a in ("%*") do ( + set "MILL_PARAMS=%%b" + ) +) + +rem -D mill.main.cli is for compatibility with Mill 0.10.9 - 0.13.0-M2 +"%MILL%" %MILL_FIRST_ARG% -D "mill.main.cli=%MILL_MAIN_CLI%" %MILL_PARAMS% From ae03dbfcd6e73ba0d5a1187cbd8b0a7472dc69d0 Mon Sep 17 00:00:00 2001 From: Piotr Chabelski Date: Tue, 15 Jul 2025 10:13:13 +0200 Subject: [PATCH 2/3] Bump Mill to 0.12.14-19-ccc31b --- .mill-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mill-version b/.mill-version index d0834a7f54..417220eaa1 100644 --- a/.mill-version +++ b/.mill-version @@ -1 +1 @@ -0.12.14 +0.12.14-19-ccc31b From 5c0a0633e3d70c00dfa354d36eeb7c6202aefdb5 Mon Sep 17 00:00:00 2001 From: Piotr Chabelski Date: Tue, 15 Jul 2025 10:36:25 +0200 Subject: [PATCH 3/3] Automatically add the new Sonatype Central Portal snapshots repository when snapshots are expected to be used --- modules/build/src/main/scala/scala/build/Bloop.scala | 4 +++- .../scala/scala/build/tests/BuildOptionsTests.scala | 8 ++++++-- .../scala/cli/commands/pgp/PgpExternalCommand.scala | 6 +++++- .../main/scala/scala/cli/internal/ScalaJsLinker.scala | 6 +++++- .../main/scala/scala/cli/launcher/LauncherCli.scala | 7 ++++++- .../src/main/scala/scala/build/Artifacts.scala | 11 +++++++++-- .../main/scala/scala/build/options/BuildOptions.scala | 4 +++- project/deps/package.mill.scala | 3 ++- 8 files changed, 39 insertions(+), 10 deletions(-) diff --git a/modules/build/src/main/scala/scala/build/Bloop.scala b/modules/build/src/main/scala/scala/build/Bloop.scala index cc5a61c2b2..dbe8aaad65 100644 --- a/modules/build/src/main/scala/scala/build/Bloop.scala +++ b/modules/build/src/main/scala/scala/build/Bloop.scala @@ -3,6 +3,7 @@ package scala.build import bloop.rifle.{BloopRifleConfig, BuildServer} import ch.epfl.scala.bsp4j import coursier.cache.FileCache +import coursier.maven.MavenRepository import coursier.util.Task import dependency.parser.ModuleParser import dependency.{AnyDependency, DependencyLike, ScalaParameters, ScalaVersion} @@ -81,7 +82,8 @@ object Bloop { Seq(Positioned.none(dep)), Seq( coursier.Repositories.sonatype("snapshots"), - coursier.Repositories.sonatypeS01("snapshots") + coursier.Repositories.sonatypeS01("snapshots"), + MavenRepository("https://central.sonatype.com/repository/maven-snapshots") ), Some(params), logger, diff --git a/modules/build/src/test/scala/scala/build/tests/BuildOptionsTests.scala b/modules/build/src/test/scala/scala/build/tests/BuildOptionsTests.scala index 4eda96df8a..4cf036c068 100644 --- a/modules/build/src/test/scala/scala/build/tests/BuildOptionsTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/BuildOptionsTests.scala @@ -1,9 +1,10 @@ package scala.build.tests import com.eed3si9n.expecty.Expecty.assert as expect -import coursier.Repositories +import coursier.{Repositories, Repository} import coursier.cache.FileCache import coursier.core.Version +import coursier.maven.MavenRepository import dependency.ScalaParameters import scala.build.Ops.* @@ -444,10 +445,13 @@ class BuildOptionsTests extends TestUtil.ScalaCliBuildSuite { .getOrElse(sys.error("cannot happen")) val repositories = build.options.finalRepositories.orThrow - expect(repositories.length == 3) + expect(repositories.length == 4) expect(repositories.contains(Repositories.sonatype("snapshots"))) expect(repositories.contains(Repositories.sonatypeS01("snapshots"))) expect(repositories.contains(Repositories.central)) + expect(repositories.contains( + MavenRepository("https://central.sonatype.com/repository/maven-snapshots") + )) } } diff --git a/modules/cli/src/main/scala/scala/cli/commands/pgp/PgpExternalCommand.scala b/modules/cli/src/main/scala/scala/cli/commands/pgp/PgpExternalCommand.scala index 3247a7b1d0..c3a134d988 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/pgp/PgpExternalCommand.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/pgp/PgpExternalCommand.scala @@ -2,6 +2,7 @@ package scala.cli.commands.pgp import coursier.Repositories import coursier.cache.{ArchiveCache, FileCache} +import coursier.maven.MavenRepository import coursier.util.Task import dependency.* @@ -185,7 +186,10 @@ object PgpExternalCommand { if (signingCliOptions.forceJvm.getOrElse(false)) { val extraRepos = if (version.endsWith("SNAPSHOT")) - Seq(Repositories.sonatype("snapshots")) + Seq( + Repositories.sonatype("snapshots"), + MavenRepository("https://central.sonatype.com/repository/maven-snapshots") + ) else Nil diff --git a/modules/cli/src/main/scala/scala/cli/internal/ScalaJsLinker.scala b/modules/cli/src/main/scala/scala/cli/internal/ScalaJsLinker.scala index f861025566..d9de903e34 100644 --- a/modules/cli/src/main/scala/scala/cli/internal/ScalaJsLinker.scala +++ b/modules/cli/src/main/scala/scala/cli/internal/ScalaJsLinker.scala @@ -2,6 +2,7 @@ package scala.cli.internal import coursier.Repositories import coursier.cache.{ArchiveCache, FileCache} +import coursier.maven.MavenRepository import coursier.util.Task import dependency.* import org.scalajs.testing.adapter.TestAdapterInitializer as TAI @@ -58,7 +59,10 @@ object ScalaJsLinker { val extraRepos = if (scalaJsVersion.endsWith("SNAPSHOT") || scalaJsCliVersion.endsWith("SNAPSHOT")) - Seq(Repositories.sonatype("snapshots")) + Seq( + Repositories.sonatype("snapshots"), + MavenRepository("https://central.sonatype.com/repository/maven-snapshots") + ) else Nil diff --git a/modules/cli/src/main/scala/scala/cli/launcher/LauncherCli.scala b/modules/cli/src/main/scala/scala/cli/launcher/LauncherCli.scala index 2d590d2460..39dcad9955 100644 --- a/modules/cli/src/main/scala/scala/cli/launcher/LauncherCli.scala +++ b/modules/cli/src/main/scala/scala/cli/launcher/LauncherCli.scala @@ -3,6 +3,7 @@ package scala.cli.launcher import coursier.Repositories import coursier.cache.FileCache import coursier.core.Version +import coursier.maven.MavenRepository import coursier.util.{Artifact, Task} import dependency.* @@ -22,7 +23,11 @@ object LauncherCli { val cache = CoursierOptions().coursierCache(logger.coursierLogger("")) val scalaVersion = options.cliScalaVersion.getOrElse(scalaCliScalaVersion(version)) val scalaParameters = ScalaParameters(scalaVersion) - val snapshotsRepo = Seq(Repositories.central, Repositories.sonatype("snapshots")) + val snapshotsRepo = Seq( + Repositories.central, + Repositories.sonatype("snapshots"), + MavenRepository("https://central.sonatype.com/repository/maven-snapshots") + ) val cliVersion: String = if (version == "nightly") resolveNightlyScalaCliVersion(cache, scalaParameters) else version diff --git a/modules/options/src/main/scala/scala/build/Artifacts.scala b/modules/options/src/main/scala/scala/build/Artifacts.scala index 31fd98e9c7..291a028a62 100644 --- a/modules/options/src/main/scala/scala/build/Artifacts.scala +++ b/modules/options/src/main/scala/scala/build/Artifacts.scala @@ -3,6 +3,7 @@ package scala.build import coursier.cache.FileCache import coursier.core.{Classifier, Module, ModuleName, Organization, Repository, Version} import coursier.error.ResolutionError +import coursier.maven.MavenRepository import coursier.util.Task import coursier.{Dependency as CsDependency, Fetch, Resolution, core as csCore, util as csUtil} import dependency.* @@ -164,7 +165,10 @@ object Artifacts { val hasSnapshots = jvmTestRunnerDependencies.exists(_.version.endsWith("SNAPSHOT")) || scalaArtifactsParamsOpt.flatMap(_.scalaNativeCliVersion).exists(_.endsWith("SNAPSHOT")) if (hasSnapshots) - Seq(coursier.Repositories.sonatype("snapshots")) + Seq( + coursier.Repositories.sonatype("snapshots"), + MavenRepository("https://central.sonatype.com/repository/maven-snapshots") + ) else Nil } @@ -427,7 +431,10 @@ object Artifacts { if addJvmRunner0 then { val maybeSnapshotRepo = if runnerVersion.endsWith("SNAPSHOT") then - Seq(coursier.Repositories.sonatype("snapshots")) + Seq( + coursier.Repositories.sonatype("snapshots"), + MavenRepository("https://central.sonatype.com/repository/maven-snapshots") + ) else Nil val runnerVersion0 = if shouldUseLegacyRunners then { diff --git a/modules/options/src/main/scala/scala/build/options/BuildOptions.scala b/modules/options/src/main/scala/scala/build/options/BuildOptions.scala index ce5e98a0d6..0eaa8618cb 100644 --- a/modules/options/src/main/scala/scala/build/options/BuildOptions.scala +++ b/modules/options/src/main/scala/scala/build/options/BuildOptions.scala @@ -1,6 +1,7 @@ package scala.build.options import coursier.cache.{ArchiveCache, FileCache} import coursier.core.{Repository, Version} +import coursier.maven.MavenRepository import coursier.parse.RepositoryParser import coursier.util.{Artifact, Task} import dependency.* @@ -261,7 +262,8 @@ final case class BuildOptions( then Seq( coursier.Repositories.sonatype("snapshots"), - coursier.Repositories.sonatypeS01("snapshots") + coursier.Repositories.sonatypeS01("snapshots"), + MavenRepository("https://central.sonatype.com/repository/maven-snapshots") ) else Nil val extraRepositories = classPathOptions.extraRepositories.filterNot(_ == "snapshots") diff --git a/project/deps/package.mill.scala b/project/deps/package.mill.scala index 16e4702e7a..6be9e561b2 100644 --- a/project/deps/package.mill.scala +++ b/project/deps/package.mill.scala @@ -300,7 +300,8 @@ object Docker { def customRepositories = Seq( coursier.Repositories.sonatype("snapshots"), - coursier.MavenRepository("https://s01.oss.sonatype.org/content/repositories/snapshots") + coursier.MavenRepository("https://s01.oss.sonatype.org/content/repositories/snapshots"), + coursier.MavenRepository("https://central.sonatype.com/repository/maven-snapshots") // Uncomment for local development // coursier.LocalRepositories.Dangerous.maven2Local )