From 056f65b90f394dd19d39a29d94c075e1361237e9 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Wed, 30 Dec 2015 01:34:39 +0100 Subject: [PATCH] No artifacts for global-plugin repo --- .../scala/coursier/core/Definitions.scala | 10 ++ .../scala/coursier/ivy/IvyRepository.scala | 105 +++++++++--------- .../main/scala/coursier/CoursierPlugin.scala | 3 +- 3 files changed, 67 insertions(+), 51 deletions(-) diff --git a/core/shared/src/main/scala/coursier/core/Definitions.scala b/core/shared/src/main/scala/coursier/core/Definitions.scala index 08a247bf7..089e0f490 100644 --- a/core/shared/src/main/scala/coursier/core/Definitions.scala +++ b/core/shared/src/main/scala/coursier/core/Definitions.scala @@ -164,4 +164,14 @@ object Artifact { overrideClassifiers: Option[Seq[String]] ): Seq[Artifact] } + + object Source { + val empty: Source = new Source { + def artifacts( + dependency: Dependency, + project: Project, + overrideClassifiers: Option[Seq[String]] + ): Seq[Artifact] = Nil + } + } } diff --git a/core/shared/src/main/scala/coursier/ivy/IvyRepository.scala b/core/shared/src/main/scala/coursier/ivy/IvyRepository.scala index 2fe8a20b9..82a77a0d7 100644 --- a/core/shared/src/main/scala/coursier/ivy/IvyRepository.scala +++ b/core/shared/src/main/scala/coursier/ivy/IvyRepository.scala @@ -82,7 +82,8 @@ case class IvyRepository( changing: Option[Boolean] = None, properties: Map[String, String] = Map.empty, withChecksums: Boolean = true, - withSignatures: Boolean = true + withSignatures: Boolean = true, + withArtifacts: Boolean = true ) extends Repository { import Repository._ @@ -165,59 +166,63 @@ case class IvyRepository( ) ++ module.attributes - val source: Artifact.Source = new Artifact.Source { - def artifacts( - dependency: Dependency, - project: Project, - overrideClassifiers: Option[Seq[String]] - ) = { + val source: Artifact.Source = + if (withArtifacts) + new Artifact.Source { + def artifacts( + dependency: Dependency, + project: Project, + overrideClassifiers: Option[Seq[String]] + ) = { - val retained = - overrideClassifiers match { - case None => - project.publications.collect { - case (conf, p) - if conf == "*" || - conf == dependency.configuration || - project.allConfigurations.getOrElse(dependency.configuration, Set.empty).contains(conf) => - p - } - case Some(classifiers) => - val classifiersSet = classifiers.toSet - project.publications.collect { - case (_, p) if classifiersSet(p.classifier) => - p + val retained = + overrideClassifiers match { + case None => + project.publications.collect { + case (conf, p) + if conf == "*" || + conf == dependency.configuration || + project.allConfigurations.getOrElse(dependency.configuration, Set.empty).contains(conf) => + p + } + case Some(classifiers) => + val classifiersSet = classifiers.toSet + project.publications.collect { + case (_, p) if classifiersSet(p.classifier) => + p + } } + + val retainedWithUrl = retained.flatMap { p => + substitute(variables( + dependency.module, + dependency.version, + p.`type`, + p.name, + p.ext + )).toList.map(p -> _) + } + + retainedWithUrl.map { case (p, url) => + var artifact = Artifact( + url, + Map.empty, + Map.empty, + p.attributes, + changing = changing.getOrElse(project.version.contains("-SNAPSHOT")) // could be more reliable + ) + + if (withChecksums) + artifact = artifact.withDefaultChecksums + if (withSignatures) + artifact = artifact.withDefaultSignature + + artifact + } } - - val retainedWithUrl = retained.flatMap { p => - substitute(variables( - dependency.module, - dependency.version, - p.`type`, - p.name, - p.ext - )).toList.map(p -> _) } - - retainedWithUrl.map { case (p, url) => - var artifact = Artifact( - url, - Map.empty, - Map.empty, - p.attributes, - changing = changing.getOrElse(project.version.contains("-SNAPSHOT")) // could be more reliable - ) - - if (withChecksums) - artifact = artifact.withDefaultChecksums - if (withSignatures) - artifact = artifact.withDefaultSignature - - artifact - } - } - } + else + Artifact.Source.empty def find[F[_]]( diff --git a/plugin/src/main/scala/coursier/CoursierPlugin.scala b/plugin/src/main/scala/coursier/CoursierPlugin.scala index c6b2109c6..8cce5ddff 100644 --- a/plugin/src/main/scala/coursier/CoursierPlugin.scala +++ b/plugin/src/main/scala/coursier/CoursierPlugin.scala @@ -81,7 +81,8 @@ object CoursierPlugin extends AutoPlugin { new File(sys.props("user.home") + "/.sbt/0.13/plugins/target/resolution-cache/").toURI.toString + "[organization]/[module](/scala_[scalaVersion])(/sbt_[sbtVersion])/[revision]/resolved.xml.[ext]", withChecksums = false, - withSignatures = false + withSignatures = false, + withArtifacts = false ) val interProjectRepo = InterProjectRepository(projects)