diff --git a/core/shared/src/main/scala/coursier/core/Resolution.scala b/core/shared/src/main/scala/coursier/core/Resolution.scala index 4b9d16e15..ec38adc46 100644 --- a/core/shared/src/main/scala/coursier/core/Resolution.scala +++ b/core/shared/src/main/scala/coursier/core/Resolution.scala @@ -762,16 +762,22 @@ case class Resolution( def artifacts: Seq[Artifact] = artifacts0(None) - def dependencyArtifacts: Seq[(Dependency, Artifact)] = + private def dependencyArtifacts0(overrideClassifiers: Option[Seq[String]]): Seq[(Dependency, Artifact)] = for { dep <- minDependencies.toSeq (source, proj) <- projectCache .get(dep.moduleVersion) .toSeq artifact <- source - .artifacts(dep, proj, None) + .artifacts(dep, proj, overrideClassifiers) } yield dep -> artifact + def dependencyArtifacts: Seq[(Dependency, Artifact)] = + dependencyArtifacts0(None) + + def dependencyClassifiersArtifacts(classifiers: Seq[String]): Seq[(Dependency, Artifact)] = + dependencyArtifacts0(Some(classifiers)) + def errors: Seq[(Dependency, Seq[String])] = for { dep <- dependencies.toSeq diff --git a/plugin/src/main/scala/coursier/CoursierPlugin.scala b/plugin/src/main/scala/coursier/CoursierPlugin.scala index 4835282af..69cceecc3 100644 --- a/plugin/src/main/scala/coursier/CoursierPlugin.scala +++ b/plugin/src/main/scala/coursier/CoursierPlugin.scala @@ -44,7 +44,8 @@ object CoursierPlugin extends AutoPlugin { } - private def task = Def.task { + private def updateTask(withClassifiers: Boolean) = Def.task { + // let's update only one module at once, for a better output // Downloads are already parallel, no need to parallelize further anyway synchronized { @@ -148,7 +149,19 @@ object CoursierPlugin extends AutoPlugin { } } - val trDepsWithArtifactsTasks = res.artifacts + val classifiers = + if (withClassifiers) + Some(transitiveClassifiers.value) + else + None + + val allArtifacts = + classifiers match { + case None => res.artifacts + case Some(cl) => res.classifiersArtifacts(cl) + } + + val trDepsWithArtifactsTasks = allArtifacts .toVector .map { a => files.file(a, checksums = checksums, logger = logger)(cachePolicy = cachePolicy).run.map((a, _)) @@ -188,8 +201,14 @@ object CoursierPlugin extends AutoPlugin { val sbtModuleReportsPerScope = configs.map { case (c, _) => c -> { val a = allExtends(c).flatMap(depsByConfig.getOrElse(_, Nil)) - res.part(a) - .dependencyArtifacts + val partialRes = res.part(a) + val depArtifacts = + classifiers match { + case None => partialRes.dependencyArtifacts + case Some(cl) => partialRes.dependencyClassifiersArtifacts(cl) + } + + depArtifacts .groupBy { case (dep, _) => dep } .map { case (dep, l) => dep -> l.map { case (_, a) => a } } .map { case (dep, artifacts) => @@ -250,7 +269,8 @@ object CoursierPlugin extends AutoPlugin { coursierVerbosity := 0, coursierResolvers <<= Tasks.coursierResolversTask, coursierCache := new File(sys.props("user.home") + "/.coursier/sbt"), - update <<= task, + update <<= updateTask(withClassifiers = false), + updateClassifiers <<= updateTask(withClassifiers = true), coursierProject <<= Tasks.coursierProjectTask, coursierProjects <<= Tasks.coursierProjectsTask )