diff --git a/build.sc b/build.sc index 30bc5196d41..b71ce9c85b2 100644 --- a/build.sc +++ b/build.sc @@ -201,7 +201,7 @@ object Deps { ivy"com.google.protobuf:protobuf-java:3.25.3", ivy"com.google.guava:guava:33.2.1-jre", ivy"org.yaml:snakeyaml:2.2", - ivy"org.apache.commons:commons-compress:[1.26.0,)" + ivy"org.apache.commons:commons-compress:1.26.0" ) /** Used in tests. */ @@ -588,8 +588,25 @@ object main extends MillStableScalaModule with BuildInfo { BuildInfo.Value("millBinPlatform", millBinPlatform(), "Mill binary platform version."), BuildInfo.Value( "millEmbeddedDeps", - T.traverse(dev.moduleDeps)(_.publishSelfDependency)() - .map(artifact => s"${artifact.group}:${artifact.id}:${artifact.version}") + ( + T.traverse( + dev.recursiveModuleDeps.collect { case m: PublishModule => m } + )( + _.publishSelfDependency + )() + .map(artifact => s"${artifact.group}:${artifact.id}:${artifact.version}") ++ + Lib.resolveDependenciesMetadata( + repositories = dev.repositoriesTask(), + dev.transitiveIvyDeps(), + Some(dev.mapDependencies()), + dev.resolutionCustomizer(), + Some(T.ctx()), + dev.coursierCacheCustomizer() + )._2.minDependencies.toSeq + .map(d => s"${d.module.organization.value}:${d.module.name.value}:${d.version}") + ) +// T.traverse(dev.moduleDeps)(_.publishSelfDependency)() +// .map(artifact => s"${artifact.group}:${artifact.id}:${artifact.version}") .mkString(","), "Dependency artifacts embedded in mill assembly by default." ), @@ -1009,7 +1026,6 @@ object contrib extends Module { def ivyDeps = Agg(Deps.requests) } - object sonatypecentral extends ContribModule { def compileModuleDeps = Seq(scalalib) def ivyDeps = Agg(Deps.sonatypeCentralClient) diff --git a/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_SDK_2_13_14.xml b/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_SDK_2_13_14.xml index 69833688c91..39cfc936520 100644 --- a/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_SDK_2_13_14.xml +++ b/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_SDK_2_13_14.xml @@ -3,9 +3,6 @@ Scala_2_13 - - - diff --git a/integration/feature/gen-idea/test/src/GenIdeaUtils.scala b/integration/feature/gen-idea/test/src/GenIdeaUtils.scala index 8cfac26a3e8..c3f8c56911a 100644 --- a/integration/feature/gen-idea/test/src/GenIdeaUtils.scala +++ b/integration/feature/gen-idea/test/src/GenIdeaUtils.scala @@ -23,7 +23,8 @@ object GenIdeaUtils { assertPartialContentMatches( found = actualResourceString, - expected = expectedResourceString + expected = expectedResourceString, + resource.toString() ) } println( @@ -33,9 +34,9 @@ object GenIdeaUtils { check.get } - def assertPartialContentMatches(found: String, expected: String): Unit = { + def assertPartialContentMatches(found: String, expected: String, context: String = ""): Unit = { if (!expected.contains(ignoreString)) { - assert(found == expected) + assert(context != null && found == expected) } val pattern = diff --git a/integration/feature/plugin-classpath/repo/build.sc b/integration/feature/plugin-classpath/repo/build.sc new file mode 100644 index 00000000000..1d90419b0b9 --- /dev/null +++ b/integration/feature/plugin-classpath/repo/build.sc @@ -0,0 +1,10 @@ +// This plugin brings a incompatible transitive version of Mill +// See https://github.com/com-lihaoyi/mill/issues/3207 +import $ivy.`com.disneystreaming.smithy4s::smithy4s-mill-codegen-plugin::0.18.22` + +import mill._ +import mill.scalalib._ + +object root extends RootModule with ScalaModule { + def scalaVersion = "3.4.2" +} diff --git a/integration/feature/plugin-classpath/test/src/MillPluginClasspathTest.scala b/integration/feature/plugin-classpath/test/src/MillPluginClasspathTest.scala new file mode 100644 index 00000000000..5e143db2d89 --- /dev/null +++ b/integration/feature/plugin-classpath/test/src/MillPluginClasspathTest.scala @@ -0,0 +1,64 @@ +package mill.integration + +import utest._ + +object MillPluginClasspathTest extends IntegrationTestSuite { + initWorkspace() + + val embeddedModules: Seq[(String, String)] = Seq( + ("com.lihaoyi", "mill-main-client"), + ("com.lihaoyi", "mill-main-api_2.13"), + ("com.lihaoyi", "mill-main-util_2.13"), + ("com.lihaoyi", "mill-main-codesig_2.13"), + ("com.lihaoyi", "mill-runner-linenumbers_2.13"), + ("com.lihaoyi", "mill-bsp_2.13"), + ("com.lihaoyi", "mill-scalanativelib-worker-api_2.13"), + ("com.lihaoyi", "mill-testrunner-entrypoint"), + ("com.lihaoyi", "mill-scalalib-api_2.13"), + ("com.lihaoyi", "mill-testrunner_2.13"), + ("com.lihaoyi", "mill-main-define_2.13"), + ("com.lihaoyi", "mill-main-resolve_2.13"), + ("com.lihaoyi", "mill-main-eval_2.13"), + ("com.lihaoyi", "mill-main_2.13"), + ("com.lihaoyi", "mill-scalalib_2.13"), + ("com.lihaoyi", "mill-scalanativelib_2.13"), + ("com.lihaoyi", "mill-scalajslib-worker-api_2.13"), + ("com.lihaoyi", "mill-scalajslib_2.13"), + ("com.lihaoyi", "mill-runner_2.13"), + ("com.lihaoyi", "mill-idea_2.13") + ) + + val tests: Tests = Tests { + test("exclusions") - { + val res1 = eval("--meta-level", "1", "resolveDepsExclusions") + assert(res1) + + val exclusions = metaValue[Seq[(String, String)]]("mill-build.resolveDepsExclusions") + val expectedExclusions = embeddedModules + + val diff = expectedExclusions.toSet.diff(exclusions.toSet) + assert(diff.isEmpty) + + } + test("runClasspath") - { + // We expect Mill core transitive dependencies to be filtered out + val res1 = eval("--meta-level", "1", "runClasspath") + assert(res1) + + val runClasspath = metaValue[Seq[String]]("mill-build.runClasspath") + + val unexpectedArtifacts = embeddedModules.map { + case (o, n) => s"${o.replaceAll("[.]", "/")}/${n}" + } + + val unexpected = unexpectedArtifacts.flatMap { a => + runClasspath.find(p => p.toString.contains(a)).map((a, _)) + }.toMap + assert(unexpected.isEmpty) + + val expected = Seq("com/disneystreaming/smithy4s/smithy4s-mill-codegen-plugin_mill0.11_2.13") + assert(expected.forall(a => runClasspath.exists(p => p.toString().contains(a)))) + } + + } +} diff --git a/integration/src/mill/integration/IntegrationTestSuite.scala b/integration/src/mill/integration/IntegrationTestSuite.scala index 90d55f9e4d0..9c9cddd1997 100644 --- a/integration/src/mill/integration/IntegrationTestSuite.scala +++ b/integration/src/mill/integration/IntegrationTestSuite.scala @@ -1,5 +1,6 @@ package mill.integration +import mill.eval.Evaluator import mill.resolve.SelectMode import mill.runner.RunnerState import os.{Path, Shellable} @@ -91,6 +92,16 @@ abstract class IntegrationTestSuite extends TestSuite { os.read(wd / "out" / segments.init / s"${segments.last}.json") } + def metaCached(selector: String): Evaluator.Cached = { + val data = meta(selector) + upickle.default.read[Evaluator.Cached](data) + } + + def metaValue[T: upickle.default.Reader](selector: String): T = { + val cached = metaCached(selector) + upickle.default.read[T](cached.value) + } + def initWorkspace(): Path = { os.remove.all(workspacePath) os.makeDir.all(workspacePath / os.up)