diff --git a/build.sc b/build.sc index 898b5561903f..b26a28b5d762 100644 --- a/build.sc +++ b/build.sc @@ -364,11 +364,13 @@ trait MillScalaModule extends ScalaModule with MillJavaModule with ScalafixModul def scalacPluginIvyDeps = super.scalacPluginIvyDeps() ++ Agg(Deps.acyclic) ++ + Agg(ivy"com.lihaoyi::unroll-plugin:0.1.12") ++ Agg.when(scalaVersion().startsWith("2.13."))(Deps.millModuledefsPlugin) def mandatoryIvyDeps = super.mandatoryIvyDeps() ++ - Agg.when(scalaVersion().startsWith("2.13."))(Deps.millModuledefs) + Seq(ivy"com.lihaoyi::unroll-annotation:0.1.12") ++ + Agg.when(scalaVersion().startsWith("2.13."))(Deps.millModuledefs) /** Default tests module. */ lazy val test: MillScalaTests = new MillScalaTests {} diff --git a/contrib/scoverage/api/src/mill/contrib/scoverage/api/ScoverageReportWorkerApi.scala b/contrib/scoverage/api/src/mill/contrib/scoverage/api/ScoverageReportWorkerApi.scala index 6003bed659e0..da8b231d9f8f 100644 --- a/contrib/scoverage/api/src/mill/contrib/scoverage/api/ScoverageReportWorkerApi.scala +++ b/contrib/scoverage/api/src/mill/contrib/scoverage/api/ScoverageReportWorkerApi.scala @@ -1,35 +1,19 @@ package mill.contrib.scoverage.api import mill.api.Ctx +import scala.annotation.unroll trait ScoverageReportWorkerApi { import ScoverageReportWorkerApi._ - @deprecated("Use other overload instead.", "Mill after 0.10.7") - def report( - reportType: ReportType, - sources: Seq[os.Path], - dataDirs: Seq[os.Path] - )(implicit - ctx: Ctx - ): Unit = { - report(reportType, sources, dataDirs, ctx.workspace) - } - def report( reportType: ReportType, sources: Seq[os.Path], dataDirs: Seq[os.Path], - sourceRoot: os.Path + @unroll sourceRoot: os.Path = null )(implicit ctx: Ctx - ): Unit = { - // FIXME: We only call the deprecated version here, to preserve binary compatibility. Remove when appropriate. - ctx.log.error( - "Binary compatibility stub may cause infinite loops with StackOverflowError. You need to implement: def report(ReportType, Seq[Path], Seq[Path], os.Path): Unit" - ) - report(reportType, sources, dataDirs) - } + ): Unit } object ScoverageReportWorkerApi { diff --git a/contrib/scoverage/worker2/src/mill/contrib/scoverage/worker/ScoverageReportWorkerImpl.scala b/contrib/scoverage/worker2/src/mill/contrib/scoverage/worker/ScoverageReportWorkerImpl.scala index 7ed7562a4935..41d5150176ee 100644 --- a/contrib/scoverage/worker2/src/mill/contrib/scoverage/worker/ScoverageReportWorkerImpl.scala +++ b/contrib/scoverage/worker2/src/mill/contrib/scoverage/worker/ScoverageReportWorkerImpl.scala @@ -4,6 +4,7 @@ import mill.contrib.scoverage.api.ScoverageReportWorkerApi import _root_.scoverage.reporter.{CoverageAggregator, ScoverageHtmlWriter, ScoverageXmlWriter} import mill.api.Ctx import mill.contrib.scoverage.api.ScoverageReportWorkerApi.ReportType +import scala.annotation.unroll /** * Scoverage Worker for Scoverage 2.x @@ -14,8 +15,9 @@ class ScoverageReportWorkerImpl extends ScoverageReportWorkerApi { reportType: ReportType, sources: Seq[os.Path], dataDirs: Seq[os.Path], - sourceRoot: os.Path - )(implicit ctx: Ctx): Unit = + sourceRoot0: os.Path = null + )(implicit ctx: Ctx): Unit = { + val sourceRoot = Option(sourceRoot0).getOrElse(ctx.workspace) try { ctx.log.info(s"Processing coverage data for ${dataDirs.size} data locations") CoverageAggregator.aggregate(dataDirs.map(_.toIO), sourceRoot.toIO) match { @@ -43,4 +45,5 @@ class ScoverageReportWorkerImpl extends ScoverageReportWorkerApi { e.printStackTrace() throw e } + } } diff --git a/example/basic/1-simple-scala/mill b/example/basic/1-simple-scala/mill new file mode 100755 index 000000000000..0e14ecbc6884 --- /dev/null +++ b/example/basic/1-simple-scala/mill @@ -0,0 +1,67 @@ +#!/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 env variable +# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION + +set -e + +if [ -z "${DEFAULT_MILL_VERSION}" ] ; then + DEFAULT_MILL_VERSION=0.11.7 +fi + +if [ -z "$MILL_VERSION" ] ; then + if [ -f ".mill-version" ] ; then + MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)" + elif [ -f ".config/mill-version" ] ; then + MILL_VERSION="$(head -n 1 .config/mill-version 2> /dev/null)" + elif [ -f "mill" ] && [ "$0" != "mill" ] ; then + MILL_VERSION=$(grep -F "DEFAULT_MILL_VERSION=" "mill" | head -n 1 | cut -d= -f2) + else + MILL_VERSION=$DEFAULT_MILL_VERSION + fi +fi + +if [ "x${XDG_CACHE_HOME}" != "x" ] ; then + MILL_DOWNLOAD_PATH="${XDG_CACHE_HOME}/mill/download" +else + MILL_DOWNLOAD_PATH="${HOME}/.cache/mill/download" +fi +MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/${MILL_VERSION}" + +version_remainder="$MILL_VERSION" +MILL_MAJOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}" +MILL_MINOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}" + +if [ ! -s "$MILL_EXEC_PATH" ] ; then + mkdir -p "$MILL_DOWNLOAD_PATH" + if [ "$MILL_MAJOR_VERSION" -gt 0 ] || [ "$MILL_MINOR_VERSION" -ge 5 ] ; then + ASSEMBLY="-assembly" + fi + DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download + MILL_VERSION_TAG=$(echo $MILL_VERSION | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/') + MILL_DOWNLOAD_URL="https://repo1.maven.org/maven2/com/lihaoyi/mill-dist/$MILL_VERSION/mill-dist-$MILL_VERSION.jar" + curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL" + chmod +x "$DOWNLOAD_FILE" + mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH" + unset DOWNLOAD_FILE + unset MILL_DOWNLOAD_URL +fi + +if [ -z "$MILL_MAIN_CLI" ] ; then + MILL_MAIN_CLI="${0}" +fi + +MILL_FIRST_ARG="" + + # first arg is a long flag for "--interactive" or starts with "-i" +if [ "$1" = "--bsp" ] || [ "${1%"-i"*}" != "$1" ] || [ "$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_VERSION + +exec $MILL_EXEC_PATH $MILL_FIRST_ARG -D "mill.main.cli=${MILL_MAIN_CLI}" "$@" diff --git a/scalalib/api/src/mill/scalalib/api/ZincWorkerApi.scala b/scalalib/api/src/mill/scalalib/api/ZincWorkerApi.scala index dc04fb91a15f..e4287151b111 100644 --- a/scalalib/api/src/mill/scalalib/api/ZincWorkerApi.scala +++ b/scalalib/api/src/mill/scalalib/api/ZincWorkerApi.scala @@ -4,6 +4,7 @@ import mill.api.{CompileProblemReporter, PathRef} import mill.api.Loose.Agg import scala.annotation.nowarn +import scala.annotation.unroll object ZincWorkerApi { type Ctx = mill.api.Ctx.Dest with mill.api.Ctx.Log with mill.api.Ctx.Home @@ -18,36 +19,9 @@ trait ZincWorkerApi { javacOptions: Seq[String], reporter: Option[CompileProblemReporter], reportCachedProblems: Boolean, - incrementalCompilation: Boolean - )(implicit ctx: ZincWorkerApi.Ctx): mill.api.Result[CompilationResult] = - compileJava( - upstreamCompileOutput = upstreamCompileOutput, - sources = sources, - compileClasspath = compileClasspath, - javacOptions = javacOptions, - reporter = reporter, - reportCachedProblems = reportCachedProblems - ): @nowarn("cat=deprecation") + @unroll incrementalCompilation: Boolean = true + )(implicit ctx: ZincWorkerApi.Ctx): mill.api.Result[CompilationResult] = ??? - /** Compile a Java-only project */ - @deprecated("Use override with `incrementalCompilation` parameter", "Mill 0.11.6") - def compileJava( - upstreamCompileOutput: Seq[CompilationResult], - sources: Agg[os.Path], - compileClasspath: Agg[os.Path], - javacOptions: Seq[String], - reporter: Option[CompileProblemReporter], - reportCachedProblems: Boolean - )(implicit ctx: ZincWorkerApi.Ctx): mill.api.Result[CompilationResult] = - compileJava( - upstreamCompileOutput = upstreamCompileOutput, - sources = sources, - compileClasspath = compileClasspath, - javacOptions = javacOptions, - reporter = reporter, - reportCachedProblems = reportCachedProblems, - incrementalCompilation = true - ) /** Compile a mixed Scala/Java or Scala-only project */ def compileMixed( @@ -62,51 +36,8 @@ trait ZincWorkerApi { scalacPluginClasspath: Agg[PathRef], reporter: Option[CompileProblemReporter], reportCachedProblems: Boolean, - incrementalCompilation: Boolean - )(implicit ctx: ZincWorkerApi.Ctx): mill.api.Result[CompilationResult] = - compileMixed( - upstreamCompileOutput = upstreamCompileOutput, - sources = sources, - compileClasspath = compileClasspath, - javacOptions = javacOptions, - scalaVersion = scalaVersion, - scalaOrganization = scalaOrganization, - scalacOptions = scalacOptions, - compilerClasspath = compilerClasspath, - scalacPluginClasspath = scalacPluginClasspath, - reporter = reporter, - reportCachedProblems = reportCachedProblems - ): @nowarn("cat=deprecation") - - /** Compile a mixed Scala/Java or Scala-only project */ - @deprecated("Use override with `incrementalCompilation` parameter", "Mill 0.11.6") - def compileMixed( - upstreamCompileOutput: Seq[CompilationResult], - sources: Agg[os.Path], - compileClasspath: Agg[os.Path], - javacOptions: Seq[String], - scalaVersion: String, - scalaOrganization: String, - scalacOptions: Seq[String], - compilerClasspath: Agg[PathRef], - scalacPluginClasspath: Agg[PathRef], - reporter: Option[CompileProblemReporter], - reportCachedProblems: Boolean - )(implicit ctx: ZincWorkerApi.Ctx): mill.api.Result[CompilationResult] = - compileMixed( - upstreamCompileOutput = upstreamCompileOutput, - sources = sources, - compileClasspath = compileClasspath, - javacOptions = javacOptions, - scalaVersion = scalaVersion, - scalaOrganization = scalaOrganization, - scalacOptions = scalacOptions, - compilerClasspath = compilerClasspath, - scalacPluginClasspath = scalacPluginClasspath, - reporter = reporter, - reportCachedProblems = reportCachedProblems, - incrementalCompilation = true - ) + @unroll incrementalCompilation: Boolean = true + )(implicit ctx: ZincWorkerApi.Ctx): mill.api.Result[CompilationResult] = ??? def discoverMainClasses(compilationResult: CompilationResult): Seq[String] diff --git a/scalalib/src/mill/scalalib/Dependency.scala b/scalalib/src/mill/scalalib/Dependency.scala index 097c2a1c2217..12821e10a5b6 100644 --- a/scalalib/src/mill/scalalib/Dependency.scala +++ b/scalalib/src/mill/scalalib/Dependency.scala @@ -5,6 +5,7 @@ import mill.define.{Command, Discover, ExternalModule} import mill.eval.Evaluator import mill.scalalib.dependency.{DependencyUpdatesImpl, Format} import mill.scalalib.dependency.updates.ModuleDependenciesUpdates +import scala.annotation.unroll object Dependency extends ExternalModule { @@ -27,14 +28,10 @@ object Dependency extends ExternalModule { def showUpdates( ev: Evaluator, allowPreRelease: Boolean = false, - format: Format = Format.PerModule + @unroll format: Format = Format.PerModule ): Command[Unit] = T.command { DependencyUpdatesImpl.showAllUpdates(updates(ev, allowPreRelease)(), format) } - @deprecated("Use other overload instead", "Mill after 0.11.6") - def showUpdates(ev: Evaluator, allowPreRelease: Boolean): Command[Unit] = - Dependency.showUpdates(ev, allowPreRelease, Format.PerModule) - lazy val millDiscover: Discover[Dependency.this.type] = Discover[this.type] } diff --git a/scalalib/src/mill/scalalib/TestModule.scala b/scalalib/src/mill/scalalib/TestModule.scala index 82ed399c94d7..7d0ef3487f13 100644 --- a/scalalib/src/mill/scalalib/TestModule.scala +++ b/scalalib/src/mill/scalalib/TestModule.scala @@ -6,6 +6,7 @@ import mill.api.{Ctx, PathRef, Result} import mill.util.Jvm import mill.scalalib.bsp.{BspBuildTarget, BspModule} import mill.testrunner.{Framework, TestArgs, TestResult, TestRunner} +import scala.annotation.unroll trait TestModule extends TaskModule with TestModule.JavaModuleBase { @@ -259,16 +260,10 @@ object TestModule { override def testFramework: T[String] = "zio.test.sbt.ZTestFramework" } - @deprecated("Use other overload instead", "Mill after 0.10.2") - def handleResults( - doneMsg: String, - results: Seq[TestResult] - ): Result[(String, Seq[TestResult])] = handleResults(doneMsg, results, None) - def handleResults( doneMsg: String, results: Seq[TestResult], - ctx: Option[Ctx.Env] + @unroll ctx: Option[Ctx.Env] = None ): Result[(String, Seq[TestResult])] = { val badTests: Seq[TestResult] = diff --git a/scalalib/src/mill/scalalib/dependency/DependencyUpdatesImpl.scala b/scalalib/src/mill/scalalib/dependency/DependencyUpdatesImpl.scala index ef22bed789d5..db008dd3884d 100644 --- a/scalalib/src/mill/scalalib/dependency/DependencyUpdatesImpl.scala +++ b/scalalib/src/mill/scalalib/dependency/DependencyUpdatesImpl.scala @@ -9,6 +9,7 @@ import mill.scalalib.dependency.updates.{ UpdatesFinder } import mill.scalalib.dependency.versions.{ModuleDependenciesVersions, VersionsFinder} +import scala.annotation.unroll object DependencyUpdatesImpl { @@ -33,13 +34,9 @@ object DependencyUpdatesImpl { allUpdates } - @deprecated("Use other overload instead", "Mill after 0.11.6") - def showAllUpdates(updates: Seq[ModuleDependenciesUpdates]): Unit = - showAllUpdates(updates, format = Format.PerModule) - def showAllUpdates( updates: Seq[ModuleDependenciesUpdates], - format: Format = Format.PerModule + @unroll format: Format = Format.PerModule ): Unit = { val theUpdates = updates.map(u => if (u.modulePath.isEmpty) u.copy(modulePath = "root module") else u)