From 59d51792ba4e8a8d6ab63928ba0f0567268b6479 Mon Sep 17 00:00:00 2001 From: Alex Archambault Date: Wed, 18 Dec 2024 13:03:32 +0100 Subject: [PATCH 1/2] Mark all workers dependencies as provided So that we don't need to resort to "resolveFilter" stuff to keep only their main JAR --- contrib/package.mill | 10 ++++++---- kotlinlib/package.mill | 12 +++++++----- scalajslib/package.mill | 6 +++--- scalanativelib/package.mill | 8 ++++---- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/contrib/package.mill b/contrib/package.mill index d11cc3a0132..e5ff1c1dce3 100644 --- a/contrib/package.mill +++ b/contrib/package.mill @@ -126,11 +126,12 @@ object `package` extends RootModule { // Worker for Scoverage 2.0 object worker2 extends build.MillPublishScalaModule { - def compileModuleDeps = Seq(build.main.api) - def moduleDeps = Seq(scoverage.api) - def testDepPaths = Task { Seq(compile().classes) } + def compileModuleDeps = Seq( + build.main.api, + scoverage.api + ) def compileIvyDeps = Task { - Agg( + super.mandatoryIvyDeps() ++ Agg( // compile-time only, need to provide the correct scoverage version at runtime build.Deps.scalacScoverage2Plugin, build.Deps.scalacScoverage2Reporter, @@ -138,6 +139,7 @@ object `package` extends RootModule { build.Deps.scalacScoverage2Serializer ) } + def mandatoryIvyDeps = Agg.empty[Dep] } } diff --git a/kotlinlib/package.mill b/kotlinlib/package.mill index 2913cb65eb2..50df85efc6f 100644 --- a/kotlinlib/package.mill +++ b/kotlinlib/package.mill @@ -45,11 +45,13 @@ object `package` extends RootModule with build.MillPublishScalaModule with Build ) object impl extends MillKotlinModule { - override def moduleDeps: Seq[PublishModule] = Seq(worker) - override def compileIvyDeps: T[Agg[Dep]] = Agg( - build.Deps.osLib, - build.Deps.kotlinCompiler - ) + override def compileModuleDeps = Seq(worker) + def mandatoryIvyDeps = Agg.empty[Dep] + override def compileIvyDeps: T[Agg[Dep]] = + super.mandatoryIvyDeps() ++ Agg( + build.Deps.osLib, + build.Deps.kotlinCompiler + ) } } } diff --git a/scalajslib/package.mill b/scalajslib/package.mill index 80bc08913dd..2dc9c3cb694 100644 --- a/scalajslib/package.mill +++ b/scalajslib/package.mill @@ -45,9 +45,9 @@ object `package` extends RootModule with build.MillStableScalaModule with BuildI trait WorkerModule extends build.MillPublishScalaModule with Cross.Module[String] { def scalajsWorkerVersion = crossValue def millSourcePath: os.Path = super.millSourcePath / scalajsWorkerVersion - def testDepPaths = Task { Seq(compile().classes) } - def moduleDeps = Seq(build.scalajslib.`worker-api`, build.main.client, build.main.api) - def ivyDeps = Agg( + def compileModuleDeps = Seq(build.scalajslib.`worker-api`, build.main.client, build.main.api) + def mandatoryIvyDeps = Agg.empty[Dep] + def compileIvyDeps = super.mandatoryIvyDeps() ++ Agg( build.Deps.Scalajs_1.scalajsLinker, build.Deps.Scalajs_1.scalajsSbtTestAdapter, build.Deps.Scalajs_1.scalajsEnvNodejs, diff --git a/scalanativelib/package.mill b/scalanativelib/package.mill index 0233b4a6c65..a0c2c525a9e 100644 --- a/scalanativelib/package.mill +++ b/scalanativelib/package.mill @@ -18,11 +18,10 @@ object `package` extends RootModule with build.MillStableScalaModule { trait WorkerModule extends build.MillPublishScalaModule with Cross.Module[String] { def scalaNativeWorkerVersion = crossValue def millSourcePath: os.Path = super.millSourcePath / scalaNativeWorkerVersion - def testDepPaths = Task { Seq(compile().classes) } - def moduleDeps = Seq(`worker-api`) - def ivyDeps = scalaNativeWorkerVersion match { + def compileModuleDeps = Seq(`worker-api`) + def compileIvyDeps = scalaNativeWorkerVersion match { case "0.5" => - Agg( + super.mandatoryIvyDeps() ++ Agg( build.Deps.osLib, build.Deps.Scalanative_0_5.scalanativeTools, build.Deps.Scalanative_0_5.scalanativeUtil, @@ -30,5 +29,6 @@ object `package` extends RootModule with build.MillStableScalaModule { build.Deps.Scalanative_0_5.scalanativeTestRunner ) } + def mandatoryIvyDeps = Agg.empty[mill.scalalib.Dep] } } From 7b4619ff18d053aa608f5a0515d8b465eedb377a Mon Sep 17 00:00:00 2001 From: Alex Archambault Date: Wed, 18 Dec 2024 01:28:04 +0100 Subject: [PATCH 2/2] Deprecate resolveFilter stuff --- .../contrib/scoverage/ScoverageModule.scala | 3 +-- kotlinlib/src/mill/kotlinlib/KotlinModule.scala | 3 +-- main/util/src/mill/util/CoursierSupport.scala | 17 ++++++++++------- main/util/src/mill/util/Util.scala | 4 ++-- .../src/mill/scalajslib/ScalaJSModule.scala | 3 +-- .../mill/scalanativelib/ScalaNativeModule.scala | 3 +-- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/contrib/scoverage/src/mill/contrib/scoverage/ScoverageModule.scala b/contrib/scoverage/src/mill/contrib/scoverage/ScoverageModule.scala index 121899d8bb3..e6514e80e3d 100644 --- a/contrib/scoverage/src/mill/contrib/scoverage/ScoverageModule.scala +++ b/contrib/scoverage/src/mill/contrib/scoverage/ScoverageModule.scala @@ -125,8 +125,7 @@ trait ScoverageModule extends ScalaModule { outer: ScalaModule => millProjectModule( workerArtifact, - repositoriesTask(), - resolveFilter = _.toString.contains(workerArtifact) + repositoriesTask() ) } diff --git a/kotlinlib/src/mill/kotlinlib/KotlinModule.scala b/kotlinlib/src/mill/kotlinlib/KotlinModule.scala index 5ce0f2c6483..826148265d6 100644 --- a/kotlinlib/src/mill/kotlinlib/KotlinModule.scala +++ b/kotlinlib/src/mill/kotlinlib/KotlinModule.scala @@ -88,8 +88,7 @@ trait KotlinModule extends JavaModule { outer => private[kotlinlib] def kotlinWorkerClasspath = Task { millProjectModule( "mill-kotlinlib-worker-impl", - repositoriesTask(), - resolveFilter = _.toString.contains("mill-kotlinlib-worker-impl") + repositoriesTask() ) } diff --git a/main/util/src/mill/util/CoursierSupport.scala b/main/util/src/mill/util/CoursierSupport.scala index 083d7f2216c..4c53ac7172d 100644 --- a/main/util/src/mill/util/CoursierSupport.scala +++ b/main/util/src/mill/util/CoursierSupport.scala @@ -52,6 +52,10 @@ trait CoursierSupport { * We do not bother breaking this out into the separate ZincWorkerApi classpath, * because Coursier is already bundled with mill/Ammonite to support the * `import $ivy` syntax. + * + * Avoid using `deprecatedResolveFilter` if you can. As a substitute, use exclusions + * (or upfront, mark some dependencies as provided aka compile-time when you publish them), + * or as a last resort, manually filter the file sequence returned by this function. */ def resolveDependencies( repositories: Seq[Repository], @@ -62,7 +66,7 @@ trait CoursierSupport { customizer: Option[Resolution => Resolution] = None, ctx: Option[mill.api.Ctx.Log] = None, coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]] = None, - resolveFilter: os.Path => Boolean = _ => true, + deprecatedResolveFilter: os.Path => Boolean = _ => true, artifactTypes: Option[Set[Type]] = None, resolutionParams: ResolutionParams = ResolutionParams() ): Result[Agg[PathRef]] = { @@ -108,7 +112,7 @@ trait CoursierSupport { Agg.from( res.files .map(os.Path(_)) - .filter(resolveFilter) + .filter(deprecatedResolveFilter) .map(PathRef(_, quick = true)) ) ++ localTestDeps.flatten ) @@ -126,7 +130,7 @@ trait CoursierSupport { customizer: Option[Resolution => Resolution], ctx: Option[mill.api.Ctx.Log], coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]], - resolveFilter: os.Path => Boolean, + deprecatedResolveFilter: os.Path => Boolean, artifactTypes: Option[Set[Type]] ): Result[Agg[PathRef]] = resolveDependencies( @@ -138,7 +142,7 @@ trait CoursierSupport { customizer, ctx, coursierCacheCustomizer, - resolveFilter, + deprecatedResolveFilter, artifactTypes, ResolutionParams() ) @@ -153,7 +157,7 @@ trait CoursierSupport { customizer: Option[Resolution => Resolution], ctx: Option[mill.api.Ctx.Log], coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]], - resolveFilter: os.Path => Boolean + deprecatedResolveFilter: os.Path => Boolean ): Result[Agg[PathRef]] = resolveDependencies( repositories, @@ -164,8 +168,7 @@ trait CoursierSupport { customizer, ctx, coursierCacheCustomizer, - resolveFilter, - None + deprecatedResolveFilter ) @deprecated( diff --git a/main/util/src/mill/util/Util.scala b/main/util/src/mill/util/Util.scala index 9b7cdc60e7d..ddd51ca7827 100644 --- a/main/util/src/mill/util/Util.scala +++ b/main/util/src/mill/util/Util.scala @@ -73,7 +73,7 @@ object Util { def millProjectModule( artifact: String, repositories: Seq[Repository], - resolveFilter: os.Path => Boolean = _ => true, + deprecatedResolveFilter: os.Path => Boolean = _ => true, // this should correspond to the mill runtime Scala version artifactSuffix: String = "_2.13" ): Result[Agg[PathRef]] = { @@ -90,7 +90,7 @@ object Util { ) ), force = Nil, - resolveFilter = resolveFilter + deprecatedResolveFilter = deprecatedResolveFilter ).map(_.map(_.withRevalidateOnce)) } diff --git a/scalajslib/src/mill/scalajslib/ScalaJSModule.scala b/scalajslib/src/mill/scalajslib/ScalaJSModule.scala index 6ecd5dc2253..3164ff532d4 100644 --- a/scalajslib/src/mill/scalajslib/ScalaJSModule.scala +++ b/scalajslib/src/mill/scalajslib/ScalaJSModule.scala @@ -52,8 +52,7 @@ trait ScalaJSModule extends scalalib.ScalaModule { outer => def scalaJSWorkerClasspath = Task { mill.util.Util.millProjectModule( artifact = s"mill-scalajslib-worker-${scalaJSWorkerVersion()}", - repositories = repositoriesTask(), - resolveFilter = _.toString.contains("mill-scalajslib-worker") + repositories = repositoriesTask() ) } diff --git a/scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala b/scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala index 3eb6e84def0..892fadfbc00 100644 --- a/scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala +++ b/scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala @@ -52,8 +52,7 @@ trait ScalaNativeModule extends ScalaModule { outer => def scalaNativeWorkerClasspath = Task { millProjectModule( s"mill-scalanativelib-worker-${scalaNativeWorkerVersion()}", - repositoriesTask(), - resolveFilter = _.toString.contains("mill-scalanativelib-worker") + repositoriesTask() ) }