diff --git a/main/util/src/mill/util/CoursierSupport.scala b/main/util/src/mill/util/CoursierSupport.scala index 6476bd0e493..0b3e5f43ede 100644 --- a/main/util/src/mill/util/CoursierSupport.scala +++ b/main/util/src/mill/util/CoursierSupport.scala @@ -32,6 +32,13 @@ trait CoursierSupport { ctx.fold(cache)(c => cache.withLogger(new TickerResolutionLogger(c))) } + /** + * A `coursier.Repository` that exposes modules with hard-coded artifact list + * + * Used in Mill tests. This exposes internal workers for example, so that these + * come from the build and not from remote repositories or ~/.ivy2/local. See + * `MillJavaModule#{testTransitiveDeps,writeLocalTestOverrides}` in the Mill build. + */ private class TestOverridesRepo(root: os.ResourcePath) extends Repository { private def listFor(mod: Module): Either[os.ResourceNotFoundException, String] = { diff --git a/scalalib/src/mill/scalalib/JavaModule.scala b/scalalib/src/mill/scalalib/JavaModule.scala index 4b3b900cf27..05566acc696 100644 --- a/scalalib/src/mill/scalalib/JavaModule.scala +++ b/scalalib/src/mill/scalalib/JavaModule.scala @@ -471,7 +471,10 @@ trait JavaModule // We pull their compile scope when our compile scope is asked, // and pull their runtime scope when our runtime scope is asked. Seq( - (cs.Configuration.compile, modDep.coursierDependency), + ( + cs.Configuration.compile, + modDep.coursierDependency.withConfiguration(cs.Configuration.compile) + ), ( cs.Configuration.runtime, modDep.coursierDependency.withConfiguration(cs.Configuration.runtime) @@ -481,17 +484,17 @@ trait JavaModule compileModuleDepsChecked.map { modDep => // Compile-only (aka provided) dependencies // We pull their compile scope when our provided scope is asked (see scopes above) - (cs.Configuration.provided, modDep.coursierDependency) + ( + cs.Configuration.provided, + modDep.coursierDependency.withConfiguration(cs.Configuration.compile) + ) } ++ runModuleDepsChecked.map { modDep => // Runtime dependencies // We pull their runtime scope when our runtime scope is pulled ( cs.Configuration.runtime, - modDep.coursierDependency.withConfiguration( - if (modDep.coursierDependency.configuration.isEmpty) cs.Configuration.runtime - else modDep.coursierDependency.configuration - ) + modDep.coursierDependency.withConfiguration(cs.Configuration.runtime) ) } @@ -502,23 +505,21 @@ trait JavaModule // We pull their compile scope when our compile scope is asked, // and pull their runtime scope when our runtime scope is asked. Seq( - (cs.Configuration.compile, dep), + (cs.Configuration.compile, dep.withConfiguration(cs.Configuration.compile)), (cs.Configuration.runtime, dep.withConfiguration(cs.Configuration.runtime)) ) } ++ compileIvyDeps().map(bindDependency()).map(_.dep).map { dep => // Compile-only (aka provided) dependencies, like above // We pull their compile scope when our provided scope is asked (see scopes above) - (cs.Configuration.provided, dep) + (cs.Configuration.provided, dep.withConfiguration(cs.Configuration.compile)) } ++ runIvyDeps().map(bindDependency()).map(_.dep).map { dep => // Runtime dependencies, like above // We pull their runtime scope when our runtime scope is pulled ( cs.Configuration.runtime, - dep.withConfiguration( - if (dep.configuration.isEmpty) cs.Configuration.runtime else dep.configuration - ) + dep.withConfiguration(cs.Configuration.runtime) ) } ++ allBomDeps().map { bomDep =>