From 275f54da40dda66018c66207f0c8ece487a3491b Mon Sep 17 00:00:00 2001 From: Alex Archambault Date: Wed, 18 Dec 2024 16:09:50 +0100 Subject: [PATCH] Missing bits from #4162 --- contrib/package.mill | 1 - main/util/src/mill/util/CoursierSupport.scala | 13 +++++++++++-- main/util/src/mill/util/Util.scala | 4 +++- scalajslib/package.mill | 1 - scalanativelib/package.mill | 1 - 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/contrib/package.mill b/contrib/package.mill index 358fab60aee..e5ff1c1dce3 100644 --- a/contrib/package.mill +++ b/contrib/package.mill @@ -130,7 +130,6 @@ object `package` extends RootModule { build.main.api, scoverage.api ) - def testDepPaths = Task { Seq(compile().classes) } def compileIvyDeps = Task { super.mandatoryIvyDeps() ++ Agg( // compile-time only, need to provide the correct scoverage version at runtime diff --git a/main/util/src/mill/util/CoursierSupport.scala b/main/util/src/mill/util/CoursierSupport.scala index f59157f1bce..6476bd0e493 100644 --- a/main/util/src/mill/util/CoursierSupport.scala +++ b/main/util/src/mill/util/CoursierSupport.scala @@ -104,6 +104,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], @@ -114,6 +118,7 @@ trait CoursierSupport { customizer: Option[Resolution => Resolution] = None, ctx: Option[mill.api.Ctx.Log] = None, coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]] = None, + deprecatedResolveFilter: os.Path => Boolean = _ => true, artifactTypes: Option[Set[Type]] = None, resolutionParams: ResolutionParams = ResolutionParams() ): Result[Agg[PathRef]] = { @@ -156,6 +161,7 @@ trait CoursierSupport { Agg.from( res.files .map(os.Path(_)) + .filter(deprecatedResolveFilter) .map(PathRef(_, quick = true)) ) ) @@ -173,6 +179,7 @@ trait CoursierSupport { customizer: Option[Resolution => Resolution], ctx: Option[mill.api.Ctx.Log], coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]], + deprecatedResolveFilter: os.Path => Boolean, artifactTypes: Option[Set[Type]] ): Result[Agg[PathRef]] = resolveDependencies( @@ -184,6 +191,7 @@ trait CoursierSupport { customizer, ctx, coursierCacheCustomizer, + deprecatedResolveFilter, artifactTypes, ResolutionParams() ) @@ -197,7 +205,8 @@ trait CoursierSupport { mapDependencies: Option[Dependency => Dependency], customizer: Option[Resolution => Resolution], ctx: Option[mill.api.Ctx.Log], - coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]] + coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]], + deprecatedResolveFilter: os.Path => Boolean ): Result[Agg[PathRef]] = resolveDependencies( repositories, @@ -208,7 +217,7 @@ trait CoursierSupport { customizer, ctx, coursierCacheCustomizer, - None + deprecatedResolveFilter ) @deprecated( diff --git a/main/util/src/mill/util/Util.scala b/main/util/src/mill/util/Util.scala index 4e7ba1be198..ddd51ca7827 100644 --- a/main/util/src/mill/util/Util.scala +++ b/main/util/src/mill/util/Util.scala @@ -73,6 +73,7 @@ object Util { def millProjectModule( artifact: String, repositories: Seq[Repository], + deprecatedResolveFilter: os.Path => Boolean = _ => true, // this should correspond to the mill runtime Scala version artifactSuffix: String = "_2.13" ): Result[Agg[PathRef]] = { @@ -88,7 +89,8 @@ object Util { BuildInfo.millVersion ) ), - force = Nil + force = Nil, + deprecatedResolveFilter = deprecatedResolveFilter ).map(_.map(_.withRevalidateOnce)) } diff --git a/scalajslib/package.mill b/scalajslib/package.mill index c4c466a6708..2dc9c3cb694 100644 --- a/scalajslib/package.mill +++ b/scalajslib/package.mill @@ -45,7 +45,6 @@ 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 compileModuleDeps = Seq(build.scalajslib.`worker-api`, build.main.client, build.main.api) def mandatoryIvyDeps = Agg.empty[Dep] def compileIvyDeps = super.mandatoryIvyDeps() ++ Agg( diff --git a/scalanativelib/package.mill b/scalanativelib/package.mill index 450fe0e413a..a0c2c525a9e 100644 --- a/scalanativelib/package.mill +++ b/scalanativelib/package.mill @@ -18,7 +18,6 @@ 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 compileModuleDeps = Seq(`worker-api`) def compileIvyDeps = scalaNativeWorkerVersion match { case "0.5" =>