From 13c29321c441f10d6419626a4a58cdd529d6ac88 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Fri, 1 Mar 2024 10:44:13 +0100 Subject: [PATCH] Update Mill from 0.10.15 to 0.11.7 Some changes are wild guesses. And it does not compile all modules. Here is one error: ``` amm.compiler[2.12.8].compile java.io.IOError: java.lang.RuntimeException: /packages cannot be represented as URI ``` --- .mill-version | 2 +- build.sc | 91 +++++++++++++++++++++++++++------------------------ ci/upload.sc | 2 +- 3 files changed, 50 insertions(+), 45 deletions(-) diff --git a/.mill-version b/.mill-version index ba788384c..b80f98e66 100644 --- a/.mill-version +++ b/.mill-version @@ -1 +1 @@ -0.10.15 +0.11.7 diff --git a/build.sc b/build.sc index 72ae7c531..48c5d8a9e 100644 --- a/build.sc +++ b/build.sc @@ -1,4 +1,5 @@ import mill._, scalalib._, publish._ +import mill.api.Lazy import mill.contrib.bloop.Bloop import mill.scalalib.api.ZincWorkerUtil._ import coursier.mavenRepositoryString @@ -180,11 +181,12 @@ trait AmmInternalModule extends CrossSbtModule with Bloop.Module { ivy"$scalaO:scala-library:$scalaV" ) } - trait AmmTests extends super.Tests with TestModule.Utest { + trait AmmTests extends CrossSbtModuleTests with TestModule.Utest { def ivyDeps = super.ivyDeps() ++ Agg(Deps.utest) def forkArgs = Seq("-Xmx2g", "-Dfile.encoding=UTF8") } - def allIvyDeps = T { transitiveIvyDeps() ++ scalaLibraryIvyDeps() } + // why is this here? +// def allIvyDeps = T { transitiveIvyDeps() ++ scalaLibraryIvyDeps() } def sources = T.sources { val sv = scalaVersion() val extraDir = @@ -229,11 +231,13 @@ trait AmmInternalModule extends CrossSbtModule with Bloop.Module { super.sources() ++ extraDir ++ extraDir2 ++ extraDir3 ++ extraDir4 } def externalSources = T { - resolveDeps(allIvyDeps, sources = true)() + resolveDeps(transitiveIvyDeps, sources = true)() + } + def repositoriesTask = T.task { + super.repositoriesTask() ++ Seq( + mvn"https://scala-ci.typesafe.com/artifactory/scala-integration" + ) } - def repositories = super.repositories ++ Seq( - mvn"https://scala-ci.typesafe.com/artifactory/scala-integration" - ) override implicit def crossSbtModuleResolver: mill.define.Cross.Resolver[CrossModuleBase] = new mill.define.Cross.Resolver[CrossModuleBase] { def resolve[V <: CrossModuleBase](c: Cross[V]): V = { @@ -245,14 +249,14 @@ trait AmmInternalModule extends CrossSbtModule with Bloop.Module { } .flatMap(prefix => c.items - .map(_._2) + .map(_.module.value) .find(_.crossScalaVersion.split('.').startsWith(prefix)) ) .collectFirst { case x => x } .getOrElse { throw new Exception( s"Unable to find compatible cross version between $crossScalaVersion and " + - c.items.map(_._2.crossScalaVersion).mkString(",") + c.items.map(_.module.value.crossScalaVersion).mkString(",") ) } @@ -273,13 +277,13 @@ trait AmmModule extends AmmInternalModule with PublishModule { ) def transitiveJars: T[Agg[PathRef]] = T { - mill.define.Target.traverse(this +: moduleDeps)(m => + mill.define.Target.traverse(transitiveModuleDeps)(m => T.task { m.jar() } )() } def transitiveSourceJars: T[Agg[PathRef]] = T { - mill.define.Target.traverse(this +: moduleDeps)(m => + mill.define.Target.traverse(transitiveModuleDeps)(m => T.task { m.sourceJar() } )() } @@ -289,11 +293,12 @@ trait AmmModule extends AmmInternalModule with PublishModule { trait AmmDependenciesResourceFileModule extends JavaModule { def dependencyResourceFileName: String def dependencyFileResources = T { - val deps0 = T.task { compileIvyDeps() ++ transitiveIvyDeps() }() +// val deps0 = T.task { compileIvyDeps() ++ transitiveIvyDeps() }() + val deps0 = transitiveCompileIvyDeps() val (_, res) = mill.modules.Jvm.resolveDependenciesMetadata( repositoriesTask(), - deps0.map(resolveCoursierDependency().apply(_)), - deps0.filter(_.force).map(resolveCoursierDependency().apply(_)), + deps0.map(_.dep), // .map(resolveCoursierDependency().apply(_)), + deps0.filter(_.force).map(_.dep), //.map(resolveCoursierDependency().apply(_)), mapDependencies = Some(mapDependencies()) ) @@ -308,8 +313,8 @@ trait AmmDependenciesResourceFileModule extends JavaModule { } } -object terminal extends Cross[TerminalModule](binCrossScalaVersions: _*) -class TerminalModule(val crossScalaVersion: String) extends AmmModule { +object terminal extends Cross[TerminalModule](binCrossScalaVersions) +trait TerminalModule extends AmmModule { def ivyDeps = T { super.ivyDeps() ++ Agg( Deps.fansi, @@ -321,9 +326,9 @@ class TerminalModule(val crossScalaVersion: String) extends AmmModule { } } -object amm extends Cross[MainModule](fullCrossScalaVersions: _*) { - object util extends Cross[UtilModule](binCrossScalaVersions: _*) - class UtilModule(val crossScalaVersion: String) extends AmmModule { +object amm extends Cross[MainModule](fullCrossScalaVersions) { + object util extends Cross[UtilModule](binCrossScalaVersions) + trait UtilModule extends AmmModule { def moduleDeps = Seq() def ivyDeps = T { super.ivyDeps() ++ Agg( @@ -338,8 +343,8 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) { (if (isScala3(crossScalaVersion)) Agg.empty[Dep] else Agg(Deps.scalaReflect(scalaVersion()))) } - object runtime extends Cross[RuntimeModule](fullCrossScalaVersions: _*) - class RuntimeModule(val crossScalaVersion: String) extends AmmModule { + object runtime extends Cross[RuntimeModule](fullCrossScalaVersions) + trait RuntimeModule extends AmmModule { def moduleDeps = Seq(amm.util(), interp.api(), amm.repl.api()) def isCrossFullScalaVersion = true def ivyDeps = super.ivyDeps() ++ Agg( @@ -351,9 +356,9 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) { ) } - object compiler extends Cross[CompilerModule](fullCrossScalaVersions: _*) { - object interface extends Cross[CompilerInterfaceModule](fullCrossScalaVersions: _*) - class CompilerInterfaceModule(val crossScalaVersion: String) extends AmmModule { + object compiler extends Cross[CompilerModule](fullCrossScalaVersions) { + object interface extends Cross[CompilerInterfaceModule](fullCrossScalaVersions) + trait CompilerInterfaceModule extends AmmModule { def isCrossFullScalaVersion = true def moduleDeps = Seq(amm.util()) def exposedClassPath = T { @@ -364,7 +369,7 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) { } } } - class CompilerModule(val crossScalaVersion: String) extends AmmModule { + trait CompilerModule extends AmmModule { def supports3 = true def moduleDeps = Seq(amm.compiler.interface(), amm.util(), amm.repl.api()) def isCrossFullScalaVersion = true @@ -397,9 +402,9 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) { object test extends AmmTests } - object interp extends Cross[InterpModule](fullCrossScalaVersions: _*) { - object api extends Cross[InterpApiModule](fullCrossScalaVersions: _*) - class InterpApiModule(val crossScalaVersion: String) extends AmmModule + object interp extends Cross[InterpModule](fullCrossScalaVersions) { + object api extends Cross[InterpApiModule](fullCrossScalaVersions) + trait InterpApiModule extends AmmModule with AmmDependenciesResourceFileModule { def moduleDeps = Seq(amm.compiler.interface(), amm.util()) def isCrossFullScalaVersion = true @@ -432,7 +437,7 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) { super.generatedSources() ++ Seq(constantsSourceDir()) } } - class InterpModule(val crossScalaVersion: String) extends AmmModule { + trait InterpModule extends AmmModule { def moduleDeps = Seq(amm.util(), amm.runtime(), amm.compiler.interface()) def isCrossFullScalaVersion = true def ivyDeps = super.ivyDeps() ++ Agg( @@ -457,10 +462,10 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) { // ) // } - object repl extends Cross[ReplModule](fullCrossScalaVersions: _*) { + object repl extends Cross[ReplModule](fullCrossScalaVersions) { - object api extends Cross[ReplApiModule](fullCrossScalaVersions: _*) - class ReplApiModule(val crossScalaVersion: String) extends AmmModule + object api extends Cross[ReplApiModule](fullCrossScalaVersions) + trait ReplApiModule extends AmmModule with AmmDependenciesResourceFileModule { def isCrossFullScalaVersion = true def dependencyResourceFileName = "amm-dependencies.txt" @@ -486,7 +491,7 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) { } } - class ReplModule(val crossScalaVersion: String) extends AmmModule { + trait ReplModule extends AmmModule { def isCrossFullScalaVersion = true def moduleDeps = Seq( amm.util(), @@ -515,7 +520,7 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) { amm.repl.api().exposedClassPath() ++ amm.compiler().exposedClassPath() ++ Seq(compile().classes) ++ - resolveDeps(T.task { compileIvyDeps() ++ transitiveIvyDeps() })() + resolveDeps(T.task { compileIvyDeps().map(bindDependency()) ++ transitiveIvyDeps() })() ) } @@ -527,7 +532,7 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) { (super.resources() ++ ReplModule.this.sources() ++ ReplModule.this.externalSources() ++ - resolveDeps(ivyDeps, sources = true)()).distinct + resolveDeps(T.task { ivyDeps().map(bindDependency()) }, sources = true)()).distinct } def ivyDeps = super.ivyDeps() ++ amm.compiler().ivyDeps() ++ Agg( Deps.scalazCore @@ -536,7 +541,7 @@ object amm extends Cross[MainModule](fullCrossScalaVersions: _*) { } } -class MainModule(val crossScalaVersion: String) extends AmmModule { +trait MainModule extends AmmModule { def isCrossFullScalaVersion = true @@ -632,7 +637,7 @@ class MainModule(val crossScalaVersion: String) extends AmmModule { amm.repl.api().exposedClassPath() ++ amm.compiler().exposedClassPath() ++ Seq(amm.repl().test.compile().classes, compile().classes) ++ - resolveDeps(T.task { compileIvyDeps() ++ transitiveIvyDeps() })() + resolveDeps(T.task { compileIvyDeps().map(bindDependency()) ++ transitiveIvyDeps() })() ) } @@ -680,8 +685,8 @@ def generateApiWhitelist(replApiCp: Seq[PathRef])(implicit ctx: mill.api.Ctx.Des PathRef(ctx.dest) } -object integration extends Cross[IntegrationModule](fullCrossScalaVersions: _*) -class IntegrationModule(val crossScalaVersion: String) extends AmmInternalModule { +object integration extends Cross[IntegrationModule](fullCrossScalaVersions) +trait IntegrationModule extends AmmInternalModule { def moduleDeps = Seq(amm()) def ivyDeps = T { super.ivyDeps() ++ ( @@ -704,8 +709,8 @@ class IntegrationModule(val crossScalaVersion: String) extends AmmInternalModule } } -object sshd extends Cross[SshdModule](fullCrossScalaVersions: _*) -class SshdModule(val crossScalaVersion: String) extends AmmModule { +object sshd extends Cross[SshdModule](fullCrossScalaVersions) +trait SshdModule extends AmmModule { def moduleDeps = Seq(amm()) def isCrossFullScalaVersion = true def ivyDeps = super.ivyDeps() ++ Agg( @@ -729,7 +734,7 @@ def unitTest(scalaBinaryVersion: String) = { .items .reverse .collectFirst { - case (List(key: String), mod) if key.startsWith(scalaBinaryVersion) => mod + case item if item.crossSegments.head.startsWith(scalaBinaryVersion) => item.module.value } .getOrElse(sys.error(s"$module doesn't have versions for $scalaBinaryVersion")) @@ -754,7 +759,7 @@ def generateConstantsFile( oldCurlUrls: Seq[(String, String)] = Nil, oldUnstableCurlUrls: Seq[(String, String)] = Nil, returnDirectory: Boolean = true -)(implicit ctx: mill.util.Ctx.Dest) = { +)(implicit ctx: mill.api.Ctx.Dest) = { val versionTxt = s""" package ammonite object Constants{ @@ -782,7 +787,7 @@ def generateConstantsFile( } def generateDependenciesFile(fileName: String, deps: Seq[coursier.Dependency])(implicit - ctx: mill.util.Ctx.Dest + ctx: mill.api.Ctx.Dest ) = { val dir = ctx.dest / "extra-resources" diff --git a/ci/upload.sc b/ci/upload.sc index 26f44ba41..430078779 100644 --- a/ci/upload.sc +++ b/ci/upload.sc @@ -1,6 +1,6 @@ #!/usr/bin/env amm -@main +@mainargs.main def apply(uploadedFile: os.Path, tagName: String, uploadName: String,