From 6de5d94dbfd09e15d78023da4914b3b24d34fc10 Mon Sep 17 00:00:00 2001 From: Alex Archambault Date: Wed, 8 Jan 2025 14:26:45 +0100 Subject: [PATCH] Switch to Mill --- .github/scripts/gpg-setup.sh | 10 - .github/workflows/ci.yml | 49 ++-- .gitignore | 2 +- .mill-version | 1 + build.sbt | 57 ----- build.sc | 95 +++++++ .../windowsansi/NativeImageFeature.java | 0 .../windowsansi/WindowsAnsiSubstitutions.java | 0 .../windowsansi/WindowsAnsi.java | 0 mill | 241 ++++++++++++++++++ mill.bat | 220 ++++++++++++++++ project/build.properties | 1 - project/plugins.sbt | 2 - .../windowsansi/PowershellRunner.java | 0 .../windowsansi/WindowsAnsiPs.java | 0 15 files changed, 581 insertions(+), 97 deletions(-) delete mode 100755 .github/scripts/gpg-setup.sh create mode 100644 .mill-version delete mode 100644 build.sbt create mode 100644 build.sc rename jni-graalvm/src/{main/java => }/io/github/alexarchambault/windowsansi/NativeImageFeature.java (100%) rename jni-graalvm/src/{main/java => }/io/github/alexarchambault/windowsansi/WindowsAnsiSubstitutions.java (100%) rename jni/src/{main/java => }/io/github/alexarchambault/windowsansi/WindowsAnsi.java (100%) create mode 100755 mill create mode 100644 mill.bat delete mode 100644 project/build.properties delete mode 100644 project/plugins.sbt rename ps/src/{main/java => }/io/github/alexarchambault/windowsansi/PowershellRunner.java (100%) rename ps/src/{main/java => }/io/github/alexarchambault/windowsansi/WindowsAnsiPs.java (100%) diff --git a/.github/scripts/gpg-setup.sh b/.github/scripts/gpg-setup.sh deleted file mode 100755 index ad58f40..0000000 --- a/.github/scripts/gpg-setup.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env sh - -# from https://github.com/coursier/apps/blob/f1d2bf568bf466a98569a85c3f23c5f3a8eb5360/.github/scripts/gpg-setup.sh - -echo $PGP_SECRET | base64 --decode | gpg --import --no-tty --batch --yes - -echo "allow-loopback-pinentry" >>~/.gnupg/gpg-agent.conf -echo "pinentry-mode loopback" >>~/.gnupg/gpg.conf - -gpg-connect-agent reloadagent /bye diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e6150b..505f1bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,36 +6,33 @@ on: tags: - "v*" pull_request: + workflow_dispatch: jobs: - test: + compile: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: coursier/cache-action@v6 - - uses: coursier/setup-action@v1 - with: - jvm: 8 - - name: Compile - run: sbtn test:compile + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: coursier/setup-action@v1 + with: + jvm: "21" + - run: ./mill __.publishLocal - publish: - if: github.event_name == 'push' + release: runs-on: ubuntu-latest + if: github.event_name == 'push' steps: - - uses: actions/checkout@v4 - - uses: coursier/cache-action@v6 - - uses: coursier/setup-action@v1 - with: - jvm: 8 - - uses: olafurpg/setup-gpg@v3 - - run: .github/scripts/gpg-setup.sh - env: - PGP_SECRET: ${{ secrets.PUBLISH_SECRET_KEY }} - - name: Release - run: sbtn ci-release - env: - PGP_SECRET: ${{ secrets.PUBLISH_SECRET_KEY }} - PGP_PASSPHRASE: ${{ secrets.PUBLISH_SECRET_KEY_PASSWORD }} - SONATYPE_USERNAME: ${{ secrets.PUBLISH_USER }} - SONATYPE_PASSWORD: ${{ secrets.PUBLISH_PASSWORD }} + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: coursier/setup-action@v1 + with: + jvm: "21" + - run: ./mill mill.scalalib.PublishModule/ --sonatypeUri https://s01.oss.sonatype.org/service/local --sonatypeSnapshotUri https://s01.oss.sonatype.org/content/repositories/snapshots + env: + MILL_PGP_SECRET_BASE64: ${{ secrets.PUBLISH_SECRET_KEY }} + MILL_PGP_PASSPHRASE: ${{ secrets.PUBLISH_SECRET_KEY_PASSWORD }} + MILL_SONATYPE_USERNAME: ${{ secrets.PUBLISH_USER }} + MILL_SONATYPE_PASSWORD: ${{ secrets.PUBLISH_PASSWORD }} diff --git a/.gitignore b/.gitignore index 816471a..3e8bbcc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -target/ +out/ .bsp/ .metals/ .vscode/ diff --git a/.mill-version b/.mill-version new file mode 100644 index 0000000..43c2417 --- /dev/null +++ b/.mill-version @@ -0,0 +1 @@ +0.12.5 diff --git a/build.sbt b/build.sbt deleted file mode 100644 index 7c81921..0000000 --- a/build.sbt +++ /dev/null @@ -1,57 +0,0 @@ - -inThisBuild(List( - organization := "io.github.alexarchambault.windows-ansi", - homepage := Some(url("https://github.com/alexarchambault/windows-ansi")), - licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), - developers := List( - Developer( - "alexarchambault", - "Alexandre Archambault", - "", - url("https://github.com/alexarchambault") - ) - ) -)) - -lazy val shared = Def.settings( - - // publishing - sonatypeProfileName := "io.github.alexarchambault", - - - // pura Java - crossPaths := false, - autoScalaLibrary := false -) - - -lazy val jni = project - .settings( - shared, - name := "windows-ansi", - libraryDependencies ++= Seq( - "org.fusesource.jansi" % "jansi" % "2.4.1", - ) - ) - -lazy val `jni-graalvm` = project - .dependsOn(jni) - .settings( - shared, - licenses := List("GPL-2.0" -> url("https://opensource.org/licenses/GPL-2.0")), - name := "windows-ansi-graalvm", - libraryDependencies ++= Seq( - "org.graalvm.nativeimage" % "svm" % "22.0.0.2" % Provided - ) - ) - -lazy val ps = project - .settings( - shared, - name := "windows-ansi-ps", - ) - -// root project -disablePlugins(MimaPlugin) -(publish / skip) := true -shared diff --git a/build.sc b/build.sc new file mode 100644 index 0000000..3b5e0e4 --- /dev/null +++ b/build.sc @@ -0,0 +1,95 @@ +import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.1` +import $ivy.`com.github.lolgab::mill-mima::0.1.1` + +import com.github.lolgab.mill.mima.Mima +import de.tobiasroeser.mill.vcs.version.VcsVersion +import mill._ +import mill.scalalib._ +import mill.scalalib.publish._ + +trait WindowsAnsiPublishModule extends PublishModule with Mima { + def pomSettings = PomSettings( + description = artifactName(), + organization = "io.github.alexarchambault.windows-ansi", + url = "https://github.com/alexarchambault/windows-ansi", + licenses = Seq( + License.`Apache-2.0`, + License.`GPL-2.0-with-classpath-exception` + ), + versionControl = VersionControl.github("alexarchambault", "windows-ansi"), + developers = Seq( + Developer("alexarchambault", "Alex Archambault", "https://github.com/alexarchambault") + ) + ) + def publishVersion = T { + val value = VcsVersion.vcsState().format() + if (value.contains("-")) { + val value0 = value.takeWhile(_ != '-') + val lastDotIdx = value0.lastIndexOf('.') + if (lastDotIdx < 0) value0 + "-SNAPSHOT" + else + value0.drop(lastDotIdx + 1).toIntOption match { + case Some(lastNum) => + val prefix = value0.take(lastDotIdx) + s"$prefix.${lastNum + 1}-SNAPSHOT" + case None => + value0 + "-SNAPSHOT" + } + } + else value + } + + def javacOptions = super.javacOptions() ++ Seq( + "--release", "8" + ) + + def mimaPreviousVersions: T[Seq[String]] = T.input { + val current = os.proc("git", "describe", "--tags", "--match", "v*") + .call() + .out.trim() + os.proc("git", "tag", "-l") + .call() + .out.lines() + .filter(_ != current) + .filter(_.startsWith("v")) + .filter(!_.contains("-")) + .map(_.stripPrefix("v")) + .map(coursier.core.Version(_)) + .sorted + .map(_.repr) + } +} + +object jni extends JavaModule with WindowsAnsiPublishModule { + def artifactName = "windows-ansi" + def ivyDeps = Agg( + ivy"org.fusesource.jansi:jansi:2.4.1" + ) +} + +object `jni-graalvm` extends JavaModule with WindowsAnsiPublishModule { + def moduleDeps = Seq(jni) + def artifactName = "windows-ansi-graalvm" + def pomSettings = super.pomSettings().copy( + licenses = Seq(License.`GPL-2.0-with-classpath-exception`) + ) + def compileIvyDeps = Agg( + ivy"org.graalvm.nativeimage:svm:22.0.0.2" + ) + def mimaPreviousVersions = { + val publishedSince = coursier.core.Version("0.0.4") + super.mimaPreviousVersions().dropWhile { v => + coursier.core.Version(v) < publishedSince + } + } +} + +object ps extends JavaModule with WindowsAnsiPublishModule { + def artifactName = "windows-ansi-ps" + def mimaPreviousVersions = { + val publishedSince = coursier.core.Version("0.0.2") + super.mimaPreviousVersions().dropWhile { v => + coursier.core.Version(v) < publishedSince + } + } +} diff --git a/jni-graalvm/src/main/java/io/github/alexarchambault/windowsansi/NativeImageFeature.java b/jni-graalvm/src/io/github/alexarchambault/windowsansi/NativeImageFeature.java similarity index 100% rename from jni-graalvm/src/main/java/io/github/alexarchambault/windowsansi/NativeImageFeature.java rename to jni-graalvm/src/io/github/alexarchambault/windowsansi/NativeImageFeature.java diff --git a/jni-graalvm/src/main/java/io/github/alexarchambault/windowsansi/WindowsAnsiSubstitutions.java b/jni-graalvm/src/io/github/alexarchambault/windowsansi/WindowsAnsiSubstitutions.java similarity index 100% rename from jni-graalvm/src/main/java/io/github/alexarchambault/windowsansi/WindowsAnsiSubstitutions.java rename to jni-graalvm/src/io/github/alexarchambault/windowsansi/WindowsAnsiSubstitutions.java diff --git a/jni/src/main/java/io/github/alexarchambault/windowsansi/WindowsAnsi.java b/jni/src/io/github/alexarchambault/windowsansi/WindowsAnsi.java similarity index 100% rename from jni/src/main/java/io/github/alexarchambault/windowsansi/WindowsAnsi.java rename to jni/src/io/github/alexarchambault/windowsansi/WindowsAnsi.java diff --git a/mill b/mill new file mode 100755 index 0000000..d087ac0 --- /dev/null +++ b/mill @@ -0,0 +1,241 @@ +#!/usr/bin/env sh + +# This is a wrapper script, that automatically download mill from GitHub release pages +# You can give the required mill version with --mill-version parameter +# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION +# +# Original Project page: https://github.com/lefou/millw +# Script Version: 0.4.12 +# +# If you want to improve this script, please also contribute your changes back! +# +# Licensed under the Apache License, Version 2.0 + +set -e + +if [ -z "${DEFAULT_MILL_VERSION}" ] ; then + DEFAULT_MILL_VERSION="0.11.4" +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 + shift + if [ "x$1" != "x" ] ; then + MILL_VERSION="$1" + shift + else + echo "You specified --mill-version without a version." 1>&2 + echo "Please provide a version that matches one provided on" 1>&2 + echo "${MILL_REPO_URL}/releases" 1>&2 + false + fi +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)" + fi +fi + +MILL_USER_CACHE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/mill" + +if [ -z "${MILL_DOWNLOAD_PATH}" ] ; then + MILL_DOWNLOAD_PATH="${MILL_USER_CACHE_DIR}/download" +fi + +# 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 '.mill-version' file or --mill-version option." 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 [ -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 + + 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 + +MILL="${MILL_DOWNLOAD_PATH}/${MILL_VERSION}" + +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 +} +try_to_use_system_mill + +# If not already downloaded, download it +if [ ! -s "${MILL}" ] ; then + + # support old non-XDG download dir + MILL_OLD_DOWNLOAD_PATH="${HOME}/.mill/download" + OLD_MILL="${MILL_OLD_DOWNLOAD_PATH}/${MILL_VERSION}" + if [ -x "${OLD_MILL}" ] ; then + MILL="${OLD_MILL}" + else + 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 + + DOWNLOAD_FILE=$(mktemp mill.XXXXXX) + + if [ "$DOWNLOAD_FROM_MAVEN" = "1" ] ; then + DOWNLOAD_URL="https://repo1.maven.org/maven2/com/lihaoyi/mill-dist/${MILL_VERSION}/mill-dist-${MILL_VERSION}.jar" + 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 + + # 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}" + + unset DOWNLOAD_FILE + unset DOWNLOAD_SUFFIX + fi +fi + +if [ -z "$MILL_MAIN_CLI" ] ; then + MILL_MAIN_CLI="${0}" +fi + +MILL_FIRST_ARG="" +if [ "$1" = "--bsp" ] || [ "$1" = "-i" ] || [ "$1" = "--interactive" ] || [ "$1" = "--no-server" ] || [ "$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 + +# 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}" "$@" \ No newline at end of file diff --git a/mill.bat b/mill.bat new file mode 100644 index 0000000..6957369 --- /dev/null +++ b/mill.bat @@ -0,0 +1,220 @@ +@echo off + +rem This is a wrapper script, that automatically download mill from GitHub release pages +rem You can give the required mill version with --mill-version parameter +rem If no version is given, it falls back to the value of DEFAULT_MILL_VERSION +rem +rem Original Project page: https://github.com/lefou/millw +rem Script Version: 0.4.12 +rem +rem If you want to improve this script, please also contribute your changes back! +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.11.4" +) + +if [!GITHUB_RELEASE_CDN!]==[] ( + set "GITHUB_RELEASE_CDN=" +) + +if [!MILL_MAIN_CLI!]==[] ( + set "MILL_MAIN_CLI=%~f0" +) + +set "MILL_REPO_URL=https://github.com/com-lihaoyi/mill" + +rem %~1% removes surrounding quotes +if [%~1%]==[--mill-version] ( + if not [%~2%]==[] ( + set MILL_VERSION=%~2% + rem shift command doesn't work within parentheses + set "STRIP_VERSION_PARAMS=true" + ) else ( + echo You specified --mill-version without a version. 1>&2 + echo Please provide a version that matches one provided on 1>&2 + echo %MILL_REPO_URL%/releases 1>&2 + exit /b 1 + ) +) + +if not defined STRIP_VERSION_PARAMS GOTO AfterStripVersionParams +rem strip the: --mill-version {version} +shift +shift +:AfterStripVersionParams + +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 + ) + ) +) + +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=%MILL_DOWNLOAD_PATH%\!MILL_VERSION!.bat + +if not exist "%MILL%" ( + set VERSION_PREFIX=%MILL_VERSION:~0,4% + rem Since 0.5.0 + set DOWNLOAD_SUFFIX=-assembly + rem Since 0.11.0 + set DOWNLOAD_FROM_MAVEN=1 + if [!VERSION_PREFIX!]==[0.0.] ( + set DOWNLOAD_SUFFIX= + set DOWNLOAD_FROM_MAVEN=0 + ) + if [!VERSION_PREFIX!]==[0.1.] ( + set DOWNLOAD_SUFFIX= + set DOWNLOAD_FROM_MAVEN=0 + ) + if [!VERSION_PREFIX!]==[0.2.] ( + set DOWNLOAD_SUFFIX= + set DOWNLOAD_FROM_MAVEN=0 + ) + if [!VERSION_PREFIX!]==[0.3.] ( + set DOWNLOAD_SUFFIX= + set DOWNLOAD_FROM_MAVEN=0 + ) + if [!VERSION_PREFIX!]==[0.4.] ( + set DOWNLOAD_SUFFIX= + set DOWNLOAD_FROM_MAVEN=0 + ) + if [!VERSION_PREFIX!]==[0.5.] ( + set DOWNLOAD_FROM_MAVEN=0 + ) + if [!VERSION_PREFIX!]==[0.6.] ( + set DOWNLOAD_FROM_MAVEN=0 + ) + if [!VERSION_PREFIX!]==[0.7.] ( + set DOWNLOAD_FROM_MAVEN=0 + ) + if [!VERSION_PREFIX!]==[0.8.] ( + set DOWNLOAD_FROM_MAVEN=0 + ) + if [!VERSION_PREFIX!]==[0.9.] ( + set DOWNLOAD_FROM_MAVEN=0 + ) + set VERSION_PREFIX=%MILL_VERSION:~0,5% + if [!VERSION_PREFIX!]==[0.10.] ( + set DOWNLOAD_FROM_MAVEN=0 + ) + set VERSION_PREFIX=%MILL_VERSION:~0,8% + if [!VERSION_PREFIX!]==[0.11.0-M] ( + set DOWNLOAD_FROM_MAVEN=0 + ) + set VERSION_PREFIX= + + for /F "delims=- tokens=1" %%A in ("!MILL_VERSION!") do set MILL_VERSION_BASE=%%A + for /F "delims=- tokens=2" %%A in ("!MILL_VERSION!") do set MILL_VERSION_MILESTONE=%%A + set VERSION_MILESTONE_START=!MILL_VERSION_MILESTONE:~0,1! + if [!VERSION_MILESTONE_START!]==[M] ( + set MILL_VERSION_TAG="!MILL_VERSION_BASE!-!MILL_VERSION_MILESTONE!" + ) else ( + set MILL_VERSION_TAG=!MILL_VERSION_BASE! + ) + + rem there seems to be no way to generate a unique temporary file path (on native Windows) + set DOWNLOAD_FILE=%MILL%.tmp + + if [!DOWNLOAD_FROM_MAVEN!]==[1] ( + set DOWNLOAD_URL=https://repo1.maven.org/maven2/com/lihaoyi/mill-dist/!MILL_VERSION!/mill-dist-!MILL_VERSION!.jar + ) else ( + set DOWNLOAD_URL=!GITHUB_RELEASE_CDN!%MILL_REPO_URL%/releases/download/!MILL_VERSION_TAG!/!MILL_VERSION!!DOWNLOAD_SUFFIX! + ) + + echo Downloading mill %MILL_VERSION% from !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 "!DOWNLOAD_URL!" -o "!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 "!DOWNLOAD_URL!" "!DOWNLOAD_FILE!" + ) + if not exist "!DOWNLOAD_FILE!" ( + echo Could not download mill %MILL_VERSION% 1>&2 + exit /b 1 + ) + + move /y "!DOWNLOAD_FILE!" "%MILL%" + + set DOWNLOAD_FILE= + set 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%]==[--repl] ( + set MILL_FIRST_ARG=%1% + ) else ( + if [%~1%]==[--help] ( + set MILL_FIRST_ARG=%1% + ) + ) + ) + ) + ) +) + +set "MILL_PARAMS=%*%" + +if not [!MILL_FIRST_ARG!]==[] ( + if defined STRIP_VERSION_PARAMS ( + for /f "tokens=1-3*" %%a in ("%*") do ( + set "MILL_PARAMS=%%d" + ) + ) else ( + for /f "tokens=1*" %%a in ("%*") do ( + set "MILL_PARAMS=%%b" + ) + ) +) else ( + if defined STRIP_VERSION_PARAMS ( + for /f "tokens=1-2*" %%a in ("%*") do ( + rem strip %%a - It's the "--mill-version" option. + rem strip %%b - it's the version number that comes after the option. + rem keep %%c - It's the remaining options. + set "MILL_PARAMS=%%c" + ) + ) +) + +"%MILL%" %MILL_FIRST_ARG% -D "mill.main.cli=%MILL_MAIN_CLI%" %MILL_PARAMS% \ No newline at end of file diff --git a/project/build.properties b/project/build.properties deleted file mode 100644 index 73df629..0000000 --- a/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -sbt.version=1.10.7 diff --git a/project/plugins.sbt b/project/plugins.sbt deleted file mode 100644 index 80643b6..0000000 --- a/project/plugins.sbt +++ /dev/null @@ -1,2 +0,0 @@ -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.2") -addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.4") diff --git a/ps/src/main/java/io/github/alexarchambault/windowsansi/PowershellRunner.java b/ps/src/io/github/alexarchambault/windowsansi/PowershellRunner.java similarity index 100% rename from ps/src/main/java/io/github/alexarchambault/windowsansi/PowershellRunner.java rename to ps/src/io/github/alexarchambault/windowsansi/PowershellRunner.java diff --git a/ps/src/main/java/io/github/alexarchambault/windowsansi/WindowsAnsiPs.java b/ps/src/io/github/alexarchambault/windowsansi/WindowsAnsiPs.java similarity index 100% rename from ps/src/main/java/io/github/alexarchambault/windowsansi/WindowsAnsiPs.java rename to ps/src/io/github/alexarchambault/windowsansi/WindowsAnsiPs.java