Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checks
run: |
git config --global user.name "CI"
./mill __.checkStyle + __[0.12.0].test + __.docJar + __.publishLocal
./mill __.checkStyle + __[1.0.0-RC1].test + __.publishLocal
- name: Publish
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release'
run: |
Expand Down
1 change: 0 additions & 1 deletion .mill-version

This file was deleted.

2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.9.0
version = 3.9.6
runner.dialect = scala213source3
fileOverride."glob:**.mill".runner.dialect = scala3Future
project.git = true
Expand Down
55 changes: 32 additions & 23 deletions build.mill
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import $repo.`https://oss.sonatype.org/content/repositories/snapshots`
import $ivy.`com.goyeau::mill-git::0.2.7-8-118f733-SNAPSHOT`
import $ivy.`com.goyeau::mill-scalafix::0.5.1-1-e3aa1ee-SNAPSHOT`
import $ivy.`org.typelevel::scalac-options:0.1.7`
//| mill-version: 1.0.0-RC1
//| mill-jvm-version: 20
//| repositories: [https://oss.sonatype.org/content/repositories/snapshots]
//| mvnDeps:
//| - com.goyeau::mill-git::0.2.7-18-d218ffa-SNAPSHOT
//| - com.goyeau::mill-scalafix::0.5.1-14-4d3f5ea-SNAPSHOT
//| - org.typelevel::scalac-options:0.1.7
import com.goyeau.mill.git.{GitVersionModule, GitVersionedPublishModule}
import com.goyeau.mill.scalafix.StyleModule
import mill.*
Expand All @@ -12,39 +15,45 @@ import mill.scalalib.publish.{Developer, License, PomSettings, VersionControl}
import org.typelevel.scalacoptions.ScalacOptions.*
import org.typelevel.scalacoptions.{ScalaVersion, ScalacOptions}

object `mill-git` extends Cross[MillGitCross]("0.12.0", "0.13.0-M1")
object `mill-git` extends Cross[MillGitCross]("1.0.0-RC1", "0.12.0")
trait MillGitCross extends Cross.Module[String] with StyleModule with GitVersionedPublishModule:
val millVersion = crossValue
override def scalaVersion = millVersion match
case millVersion if millVersion.startsWith("0.12") => "2.13.16"
case millVersion if millVersion.startsWith("0.13") => "3.6.3"
case millVersion if millVersion.startsWith("1.0") => "3.7.0"
override def scalacOptions = super.scalacOptions() ++ ScalacOptions.tokensForVersion(
ScalaVersion.unsafeFromString(scalaVersion()),
ScalacOptions.default + source3 ++ fatalWarningOptions
ScalacOptions.default + source3 // ++ fatalWarningOptions Reenable this once we drop support for Scala 2/0.12.x
)

override def compileIvyDeps = super.compileIvyDeps() ++ Agg(
ivy"com.lihaoyi::mill-main:$millVersion",
ivy"com.lihaoyi::mill-scalalib:$millVersion",
ivy"com.lihaoyi::mill-contrib-docker:$millVersion"
)
override def ivyDeps = super.ivyDeps() ++ Agg(ivy"org.eclipse.jgit:org.eclipse.jgit:7.1.0.202411261347-r")
override def compileMvnDeps = super.compileMvnDeps() ++ (millVersion match
case version if version.startsWith("1.0") =>
Seq(
mvn"com.lihaoyi::mill-libs-main:$millVersion",
mvn"com.lihaoyi::mill-libs-scalalib-api:$millVersion",
mvn"com.lihaoyi::mill-contrib-docker:$millVersion"
)
case _ =>
Seq(
mvn"com.lihaoyi::mill-main:$millVersion",
mvn"com.lihaoyi::mill-scalalib:$millVersion",
mvn"com.lihaoyi::mill-contrib-docker:$millVersion"
))
override def mvnDeps = super.mvnDeps() ++ Seq(mvn"org.eclipse.jgit:org.eclipse.jgit:7.1.0.202411261347-r")

object test extends ScalaTests with TestModule.Munit:
override def ivyDeps = Agg(
ivy"org.scalameta::munit::1.1.0",
ivy"com.lihaoyi::mill-testkit:$millVersion"
override def mvnDeps = Seq(
mvn"org.scalameta::munit::1.1.0",
mvn"com.lihaoyi::mill-testkit:$millVersion"
)
override def forkEnv = Map("MILL_EXECUTABLE_PATH" -> millExecutable.assembly().path.toString)

// Create a Mill executable configured for testing our plugin
object millExecutable extends JavaModule:
override def ivyDeps = Agg(ivy"com.lihaoyi:mill-dist:$millVersion")
override def mainClass = Some("mill.runner.client.MillClientMain")
override def resources = Task:
val p = dest / MillGitCross.this.artifactId()
os.write(p, MillGitCross.this.localClasspath().map(_.path).mkString("\n"), createFolders = true)
Seq(PathRef(dest))
override def mvnDeps = millVersion match
case version if version.startsWith("1.0") => Seq(mvn"com.lihaoyi:mill-runner-launcher_3:$millVersion")
case _ => Seq(mvn"com.lihaoyi:mill-dist:$millVersion")
override def mainClass = Some("mill.launcher.MillLauncherMain")
end test

override def artifactName = s"mill-git_mill${millBinaryVersion(millVersion)}"
Expand All @@ -61,5 +70,5 @@ end MillGitCross

def millBinaryVersion(millVersion: String) = millVersion match
case version if version.startsWith("0.12") => "0.11" // 0.12.x is binary compatible with 0.11.x
case version if version.startsWith("0.13") => "0.13.0-M1"
case version if version.startsWith("1.0") => "1"
case _ => throw IllegalArgumentException(s"Unsupported Mill version: $millVersion")
188 changes: 125 additions & 63 deletions mill
Original file line number Diff line number Diff line change
@@ -1,20 +1,39 @@
#!/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
# This is a wrapper script, that automatically selects or downloads Mill from Maven Central or GitHub release pages.
#
# Original Project page: https://github.com/lefou/millw
# Script Version: 0.4.12
# 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

set -e

if [ -z "${DEFAULT_MILL_VERSION}" ] ; then
DEFAULT_MILL_VERSION=0.13.0-M0
DEFAULT_MILL_VERSION=1.0.0-RC1
fi


Expand All @@ -31,16 +50,17 @@ 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
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,
Expand All @@ -52,6 +72,8 @@ if [ -z "${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
fi

Expand All @@ -65,7 +87,7 @@ fi
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
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 || (
Expand Down Expand Up @@ -102,11 +124,10 @@ if [ -z "${MILL_VERSION}" ] ; then
fi

MILL_NATIVE_SUFFIX="-native"
MILL_JVM_SUFFIX="-jvm"
FULL_MILL_VERSION=$MILL_VERSION
ARTIFACT_SUFFIX=""
case "$MILL_VERSION" in
*"$MILL_NATIVE_SUFFIX")
MILL_VERSION=${MILL_VERSION%"$MILL_NATIVE_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"
Expand All @@ -123,9 +144,39 @@ case "$MILL_VERSION" in
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

MILL="${MILL_DOWNLOAD_PATH}/${FULL_MILL_VERSION}"
MILL="${MILL_DOWNLOAD_PATH}/$MILL_VERSION$ARTIFACT_SUFFIX"

try_to_use_system_mill() {
if [ "$(uname)" != "Linux" ]; then
Expand Down Expand Up @@ -198,57 +249,67 @@ EOF
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}"
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
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${ARTIFACT_SUFFIX}/${MILL_VERSION}/mill-dist${ARTIFACT_SUFFIX}-${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}"
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

unset DOWNLOAD_FILE
unset DOWNLOAD_SUFFIX
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}"

unset DOWNLOAD_FILE
unset DOWNLOAD_SUFFIX
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
if [ "$1" = "--bsp" ] || [ "$1" = "-i" ] || [ "$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
Expand All @@ -260,6 +321,7 @@ 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}" "$@"
exec "${MILL}" $MILL_FIRST_ARG -D "mill.main.cli=${MILL_MAIN_CLI}" "$@"
1 change: 0 additions & 1 deletion mill-git/src/com/goyeau/mill/git/GitVersionModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.goyeau.mill.git
import mill.*
import mill.Task.workspace
import mill.api.Result
import mill.define.Command
import mill.define.Discover
import mill.define.ExternalModule
import org.eclipse.jgit.api.Git
Expand Down
6 changes: 4 additions & 2 deletions mill-git/test/resources/custom/build.mill
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import $ivy.`com.goyeau::mill-git::0.2.6`
//| repositories: [https://oss.sonatype.org/content/repositories/snapshots]
//| mvnDeps:
//| - com.goyeau::mill-git::0.2.7-18-d218ffa-SNAPSHOT
import com.goyeau.mill.git.GitVersionModule
import mill._
import mill.scalalib.JavaModule
import os._

object project extends JavaModule {
def jobVersion = T(GitVersionModule.version()())
def jobVersion = Task(GitVersionModule.version()())
}

/** Usage
Expand Down
Loading