From 59d51792ba4e8a8d6ab63928ba0f0567268b6479 Mon Sep 17 00:00:00 2001 From: Alex Archambault Date: Wed, 18 Dec 2024 13:03:32 +0100 Subject: [PATCH 1/6] 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/6] 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() ) } From 36a308403ad514c237eb80e22d00618bd8d9e3a2 Mon Sep 17 00:00:00 2001 From: Alex Archambault Date: Tue, 7 Jan 2025 23:45:07 +0100 Subject: [PATCH 3/6] debug android stuff --- .../javalib/android/AndroidAppModule.scala | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scalalib/src/mill/javalib/android/AndroidAppModule.scala b/scalalib/src/mill/javalib/android/AndroidAppModule.scala index 9d2e81d4da1..a863a7b0607 100644 --- a/scalalib/src/mill/javalib/android/AndroidAppModule.scala +++ b/scalalib/src/mill/javalib/android/AndroidAppModule.scala @@ -784,7 +784,7 @@ trait AndroidAppModule extends JavaModule { "--device", androidDeviceId, "--force" - )) + ), stdin = os.InheritRaw, stdout = os.InheritRaw) if (command.exitCode != 0) { T.log.error(s"Failed to create android virtual device: ${command.err.text()}") throw new Exception(s"Failed to create android virtual device: ${command.exitCode}") @@ -810,7 +810,7 @@ trait AndroidAppModule extends JavaModule { * * @return The log line that indicates the emulator is ready */ - def startAndroidEmulator: T[Option[String]] = Task { + def startAndroidEmulator() = Task.Command { val ciSettings = Seq( "-no-snapshot-save", "-no-window", @@ -827,6 +827,7 @@ trait AndroidAppModule extends JavaModule { val command = Seq( androidSdkModule().emulatorPath().path.toString(), "-delay-adb", + "-verbose", "-port", androidEmulatorPort ) ++ settings ++ Seq("-avd", androidVirtualDeviceIdentifier) @@ -834,7 +835,8 @@ trait AndroidAppModule extends JavaModule { T.log.debug(s"Starting emulator with command ${command.mkString(" ")}") val startEmuCmd = os.spawn( - command + command, stdin = os.InheritRaw, + destroyOnExit = false ) val bootMessage = startEmuCmd.stdout.buffered.lines().filter(l => { @@ -851,14 +853,16 @@ trait AndroidAppModule extends JavaModule { bootMessage } - def waitForDevice: Target[String] = Task { + def waitForDevice() = Task.Command { val emulator = runningEmulator() + System.err.println("Running first command") os.call(( androidSdkModule().adbPath().path, "-s", emulator, "wait-for-device" - )) + ), stdin = os.InheritRaw, stdout = os.InheritRaw) + System.err.println("Running second command") val bootflag = os.call( ( androidSdkModule().adbPath().path, @@ -867,7 +871,9 @@ trait AndroidAppModule extends JavaModule { "shell", "getprop", "sys.boot_completed" - ) + ), + stdin = os.InheritRaw, + stdout = os.InheritRaw ) T.log.info(s"$emulator, bootflag is $bootflag") @@ -878,7 +884,7 @@ trait AndroidAppModule extends JavaModule { /** * Stops the android emulator */ - def stopAndroidEmulator: T[String] = Task { + def stopAndroidEmulator() = Task.Command { val emulator = runningEmulator() os.call( (androidSdkModule().adbPath().path, "-s", emulator, "emu", "kill") From bd098e3e185606f4b7ab7e56f32c236ac029985f Mon Sep 17 00:00:00 2001 From: Alex Archambault Date: Tue, 7 Jan 2025 23:48:31 +0100 Subject: [PATCH 4/6] Revert "debug android stuff" This reverts commit 36a308403ad514c237eb80e22d00618bd8d9e3a2. --- .../javalib/android/AndroidAppModule.scala | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/scalalib/src/mill/javalib/android/AndroidAppModule.scala b/scalalib/src/mill/javalib/android/AndroidAppModule.scala index a863a7b0607..9d2e81d4da1 100644 --- a/scalalib/src/mill/javalib/android/AndroidAppModule.scala +++ b/scalalib/src/mill/javalib/android/AndroidAppModule.scala @@ -784,7 +784,7 @@ trait AndroidAppModule extends JavaModule { "--device", androidDeviceId, "--force" - ), stdin = os.InheritRaw, stdout = os.InheritRaw) + )) if (command.exitCode != 0) { T.log.error(s"Failed to create android virtual device: ${command.err.text()}") throw new Exception(s"Failed to create android virtual device: ${command.exitCode}") @@ -810,7 +810,7 @@ trait AndroidAppModule extends JavaModule { * * @return The log line that indicates the emulator is ready */ - def startAndroidEmulator() = Task.Command { + def startAndroidEmulator: T[Option[String]] = Task { val ciSettings = Seq( "-no-snapshot-save", "-no-window", @@ -827,7 +827,6 @@ trait AndroidAppModule extends JavaModule { val command = Seq( androidSdkModule().emulatorPath().path.toString(), "-delay-adb", - "-verbose", "-port", androidEmulatorPort ) ++ settings ++ Seq("-avd", androidVirtualDeviceIdentifier) @@ -835,8 +834,7 @@ trait AndroidAppModule extends JavaModule { T.log.debug(s"Starting emulator with command ${command.mkString(" ")}") val startEmuCmd = os.spawn( - command, stdin = os.InheritRaw, - destroyOnExit = false + command ) val bootMessage = startEmuCmd.stdout.buffered.lines().filter(l => { @@ -853,16 +851,14 @@ trait AndroidAppModule extends JavaModule { bootMessage } - def waitForDevice() = Task.Command { + def waitForDevice: Target[String] = Task { val emulator = runningEmulator() - System.err.println("Running first command") os.call(( androidSdkModule().adbPath().path, "-s", emulator, "wait-for-device" - ), stdin = os.InheritRaw, stdout = os.InheritRaw) - System.err.println("Running second command") + )) val bootflag = os.call( ( androidSdkModule().adbPath().path, @@ -871,9 +867,7 @@ trait AndroidAppModule extends JavaModule { "shell", "getprop", "sys.boot_completed" - ), - stdin = os.InheritRaw, - stdout = os.InheritRaw + ) ) T.log.info(s"$emulator, bootflag is $bootflag") @@ -884,7 +878,7 @@ trait AndroidAppModule extends JavaModule { /** * Stops the android emulator */ - def stopAndroidEmulator() = Task.Command { + def stopAndroidEmulator: T[String] = Task { val emulator = runningEmulator() os.call( (androidSdkModule().adbPath().path, "-s", emulator, "emu", "kill") From da8b72ab970e68be8e1c48f8861da2b08502d648 Mon Sep 17 00:00:00 2001 From: Alex Archambault Date: Wed, 8 Jan 2025 20:51:39 +0100 Subject: [PATCH 5/6] Empty commit to trigger CI From e1b8d8521b8c64e645979a7d5b32e60863c7659b Mon Sep 17 00:00:00 2001 From: Alex Archambault Date: Fri, 10 Jan 2025 14:56:56 +0100 Subject: [PATCH 6/6] Add deprecated annotations on deprecatedResolveFilter --- main/util/src/mill/util/CoursierSupport.scala | 3 +++ main/util/src/mill/util/Util.scala | 1 + 2 files changed, 4 insertions(+) diff --git a/main/util/src/mill/util/CoursierSupport.scala b/main/util/src/mill/util/CoursierSupport.scala index 4c53ac7172d..89ef3a25993 100644 --- a/main/util/src/mill/util/CoursierSupport.scala +++ b/main/util/src/mill/util/CoursierSupport.scala @@ -66,6 +66,7 @@ trait CoursierSupport { customizer: Option[Resolution => Resolution] = None, ctx: Option[mill.api.Ctx.Log] = None, coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]] = None, + @deprecated("This parameter is now ignored, use exclusions instead or mark some dependencies as provided when you publish modules", "Mill after 0.12.5") deprecatedResolveFilter: os.Path => Boolean = _ => true, artifactTypes: Option[Set[Type]] = None, resolutionParams: ResolutionParams = ResolutionParams() @@ -130,6 +131,7 @@ trait CoursierSupport { customizer: Option[Resolution => Resolution], ctx: Option[mill.api.Ctx.Log], coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]], + @deprecated("This parameter is now ignored, use exclusions instead or mark some dependencies as provided when you publish modules", "Mill after 0.12.5") deprecatedResolveFilter: os.Path => Boolean, artifactTypes: Option[Set[Type]] ): Result[Agg[PathRef]] = @@ -157,6 +159,7 @@ trait CoursierSupport { customizer: Option[Resolution => Resolution], ctx: Option[mill.api.Ctx.Log], coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]], + @deprecated("This parameter is now ignored, use exclusions instead or mark some dependencies as provided when you publish modules", "Mill after 0.12.5") deprecatedResolveFilter: os.Path => Boolean ): Result[Agg[PathRef]] = resolveDependencies( diff --git a/main/util/src/mill/util/Util.scala b/main/util/src/mill/util/Util.scala index 7bfb985f7de..f4951865366 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], + @deprecated("This parameter is now ignored, use exclusions instead or mark some dependencies as provided when you publish modules", "Mill after 0.12.5") deprecatedResolveFilter: os.Path => Boolean = _ => true, // this should correspond to the mill runtime Scala version artifactSuffix: String = "_2.13"