From 5306eae55d7419c119a4b0f0ff24c3ab09879c8a Mon Sep 17 00:00:00 2001 From: Joan Goyeau Date: Sat, 22 Feb 2025 03:21:07 -0500 Subject: [PATCH] Build definition on Mill 0.13 --- .mill-version | 2 +- .scalafix.conf | 7 ++-- .scalafmt.conf | 6 ++-- build.mill | 34 +++++++++---------- mill | 30 ++++++++++++++-- .../mill/git/GitTaggedDockerModule.scala | 2 +- .../goyeau/mill/git/GitVersionModule.scala | 11 ++++-- .../mill/git/GitVersionedPublishModule.scala | 2 +- 8 files changed, 62 insertions(+), 32 deletions(-) diff --git a/.mill-version b/.mill-version index 6799343..346b1ba 100644 --- a/.mill-version +++ b/.mill-version @@ -1 +1 @@ -0.12.5 \ No newline at end of file +0.13.0-M0-93-a6992e \ No newline at end of file diff --git a/.scalafix.conf b/.scalafix.conf index df0438a..8edcabf 100644 --- a/.scalafix.conf +++ b/.scalafix.conf @@ -3,11 +3,14 @@ rules = [ DisableSyntax LeakingImplicitClassVal NoValInForComprehension - ProcedureSyntax + NoAutoTupling + OrganizeImports + RedundantSyntax ] +OrganizeImports.targetDialect = Auto DisableSyntax.noVars = true -DisableSyntax.noThrows = true +DisableSyntax.noThrows = false DisableSyntax.noNulls = true DisableSyntax.noReturns = true DisableSyntax.noAsInstanceOf = true diff --git a/.scalafmt.conf b/.scalafmt.conf index 17e8d01..71050ab 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,9 +1,9 @@ -version = 3.8.6 +version = 3.9.0 runner.dialect = scala213source3 project.git = true maxColumn = 120 align.preset = more assumeStandardLibraryStripMargin = true -rewrite.rules = [AvoidInfix, SortImports, RedundantBraces, RedundantParens, SortModifiers] +rewrite.rules = [AvoidInfix, RedundantBraces, RedundantParens, SortModifiers, Imports] rewrite.redundantBraces.stringInterpolation = true -spaces.afterTripleEquals = true +rewrite.imports.sort = original diff --git a/build.mill b/build.mill index dc3fb60..07542b2 100644 --- a/build.mill +++ b/build.mill @@ -1,22 +1,23 @@ -import $ivy.`com.goyeau::mill-git::0.2.6` -import $ivy.`com.goyeau::mill-scalafix::0.4.2` +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` import com.goyeau.mill.git.{GitVersionModule, GitVersionedPublishModule} import com.goyeau.mill.scalafix.StyleModule -import mill._ +import mill.* import mill.Task.dest -import mill.scalalib._ +import mill.define.Cross +import mill.scalalib.* import mill.scalalib.publish.{Developer, License, PomSettings, VersionControl} -import org.typelevel.scalacoptions.ScalacOptions._ +import org.typelevel.scalacoptions.ScalacOptions.* import org.typelevel.scalacoptions.{ScalaVersion, ScalacOptions} object `mill-git` extends Cross[MillGitCross]("0.12.0", "0.13.0-M0-93-a6992e") -trait MillGitCross extends Cross.Module[String] with StyleModule with GitVersionedPublishModule { - val millVersion = crossValue - override def scalaVersion = millVersion match { +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" - } override def scalacOptions = super.scalacOptions() ++ ScalacOptions.tokensForVersion( ScalaVersion.unsafeFromString(scalaVersion()), ScalacOptions.default + source3 ++ fatalWarningOptions @@ -29,7 +30,7 @@ trait MillGitCross extends Cross.Module[String] with StyleModule with GitVersion ) override def ivyDeps = super.ivyDeps() ++ Agg(ivy"org.eclipse.jgit:org.eclipse.jgit:7.1.0.202411261347-r") - object test extends ScalaTests with TestModule.Munit { + object test extends ScalaTests with TestModule.Munit: override def ivyDeps = Agg( ivy"org.scalameta::munit::1.1.0", ivy"com.lihaoyi::mill-testkit:$millVersion" @@ -37,16 +38,14 @@ trait MillGitCross extends Cross.Module[String] with StyleModule with GitVersion override def forkEnv = Map("MILL_EXECUTABLE_PATH" -> millExecutable.assembly().path.toString) // Create a Mill executable configured for testing our plugin - object millExecutable extends JavaModule { + 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 = T { + 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)) - } - } - } + end test override def artifactName = s"mill-git_mill${millBinaryVersion(millVersion)}" override def publishVersion = GitVersionModule.version(withSnapshotSuffix = true)() @@ -58,10 +57,9 @@ trait MillGitCross extends Cross.Module[String] with StyleModule with GitVersion versionControl = VersionControl.github("joan38", "mill-git"), developers = Seq(Developer("joan38", "Joan Goyeau", "https://github.com/joan38")) ) -} +end MillGitCross -def millBinaryVersion(millVersion: String) = millVersion match { +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-M0" case _ => throw new IllegalArgumentException(s"Unsupported Mill version: $millVersion") -} diff --git a/mill b/mill index 8eda811..d6c393d 100755 --- a/mill +++ b/mill @@ -14,7 +14,7 @@ set -e if [ -z "${DEFAULT_MILL_VERSION}" ] ; then - DEFAULT_MILL_VERSION=0.12.5 + DEFAULT_MILL_VERSION=0.13.0-M0 fi @@ -101,7 +101,31 @@ if [ -z "${MILL_VERSION}" ] ; then fi fi -MILL="${MILL_DOWNLOAD_PATH}/${MILL_VERSION}" +MILL_NATIVE_SUFFIX="-native" +FULL_MILL_VERSION=$MILL_VERSION +ARTIFACT_SUFFIX="" +case "$MILL_VERSION" in + *"$MILL_NATIVE_SUFFIX") + MILL_VERSION=${MILL_VERSION%"$MILL_NATIVE_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 +esac + +MILL="${MILL_DOWNLOAD_PATH}/${FULL_MILL_VERSION}" try_to_use_system_mill() { if [ "$(uname)" != "Linux" ]; then @@ -200,7 +224,7 @@ if [ ! -s "${MILL}" ] ; then 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" + 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}" diff --git a/mill-git/src/com/goyeau/mill/git/GitTaggedDockerModule.scala b/mill-git/src/com/goyeau/mill/git/GitTaggedDockerModule.scala index 2cae471..837838a 100644 --- a/mill-git/src/com/goyeau/mill/git/GitTaggedDockerModule.scala +++ b/mill-git/src/com/goyeau/mill/git/GitTaggedDockerModule.scala @@ -1,6 +1,6 @@ package com.goyeau.mill.git -import mill._ +import mill.* import mill.contrib.docker.DockerModule import mill.scalalib.JavaModule diff --git a/mill-git/src/com/goyeau/mill/git/GitVersionModule.scala b/mill-git/src/com/goyeau/mill/git/GitVersionModule.scala index 7d6516c..b1c4343 100644 --- a/mill-git/src/com/goyeau/mill/git/GitVersionModule.scala +++ b/mill-git/src/com/goyeau/mill/git/GitVersionModule.scala @@ -1,13 +1,18 @@ package com.goyeau.mill.git import mill.* -import mill.api.Result import mill.Task.workspace -import mill.define.{Command, Discover, ExternalModule} +import mill.api.Result +import mill.define.Command +import mill.define.Discover +import mill.define.ExternalModule import org.eclipse.jgit.api.Git import org.eclipse.jgit.lib.RepositoryBuilder import os.* -import scala.util.{Failure as TryFailure, Success as TrySuccess, Try} + +import scala.util.Failure as TryFailure +import scala.util.Success as TrySuccess +import scala.util.Try object GitVersionModule extends ExternalModule { diff --git a/mill-git/src/com/goyeau/mill/git/GitVersionedPublishModule.scala b/mill-git/src/com/goyeau/mill/git/GitVersionedPublishModule.scala index 91a0870..5624f5c 100644 --- a/mill-git/src/com/goyeau/mill/git/GitVersionedPublishModule.scala +++ b/mill-git/src/com/goyeau/mill/git/GitVersionedPublishModule.scala @@ -1,6 +1,6 @@ package com.goyeau.mill.git -import mill._ +import mill.* import mill.scalalib.PublishModule trait GitVersionedPublishModule extends PublishModule {