From 9968a12d10c85248dce8901bf8a1861a2e51c2a4 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Wed, 19 Sep 2018 15:34:54 +0200 Subject: [PATCH] Tweak Ivy repositories artifact handling --- .../scala/coursier/ivy/IvyRepository.scala | 9 ++++-- .../test/scala/coursier/test/IvyTests.scala | 28 +++++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/core/shared/src/main/scala/coursier/ivy/IvyRepository.scala b/core/shared/src/main/scala/coursier/ivy/IvyRepository.scala index 05192d1b5..09239a120 100644 --- a/core/shared/src/main/scala/coursier/ivy/IvyRepository.scala +++ b/core/shared/src/main/scala/coursier/ivy/IvyRepository.scala @@ -79,9 +79,12 @@ final case class IvyRepository( } else if (dependency.attributes.`type`.nonEmpty) project.publications.collect { - case (_, p) - if p.classifier.isEmpty && ( - p.`type` == dependency.attributes.`type` || + case (conf, p) + if (conf == "*" || + conf == dependency.configuration || + project.allConfigurations.getOrElse(dependency.configuration, Set.empty).contains(conf)) && + ( + p.`type` == dependency.attributes.`type` || (p.ext == dependency.attributes.`type` && project.packagingOpt.toSeq.contains(p.`type`)) // wow ) => p diff --git a/tests/jvm/src/test/scala/coursier/test/IvyTests.scala b/tests/jvm/src/test/scala/coursier/test/IvyTests.scala index f8a075244..ebebdc142 100644 --- a/tests/jvm/src/test/scala/coursier/test/IvyTests.scala +++ b/tests/jvm/src/test/scala/coursier/test/IvyTests.scala @@ -81,14 +81,26 @@ object IvyTests extends TestSuite { throw new Exception(s"Unexpected number of artifacts\n${other.mkString("\n")}") } - "test conf" - CentralTests.withArtifacts( - dep = dep.copy(configuration = "test"), - extraRepos = Seq(repo), - classifierOpt = None - ) { artifacts => - val urls = artifacts.map(_.url).toSet - assert(urls(mainJarUrl)) - assert(urls(testJarUrl)) + "test conf" - { + "no attributes" - CentralTests.withArtifacts( + dep = dep.copy(configuration = "test"), + extraRepos = Seq(repo), + classifierOpt = None + ) { artifacts => + val urls = artifacts.map(_.url).toSet + assert(urls(mainJarUrl)) + assert(urls(testJarUrl)) + } + + "attributes" - CentralTests.withArtifacts( + dep = dep.copy(configuration = "test", attributes = Attributes("jar")), + extraRepos = Seq(repo), + classifierOpt = None + ) { artifacts => + val urls = artifacts.map(_.url).toSet + assert(urls(mainJarUrl)) + assert(urls(testJarUrl)) + } } "tests classifier" - {