From 9b64b75c2fb2a1a4b664df1f2a4498cd718c3d6c Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Fri, 15 Apr 2011 18:31:16 -0400 Subject: [PATCH] Hack to avoid Ivy checking for sources/javadocs for every module --- ivy/Ivy.scala | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ivy/Ivy.scala b/ivy/Ivy.scala index 1614d7cd2..f570a0761 100644 --- a/ivy/Ivy.scala +++ b/ivy/Ivy.scala @@ -21,7 +21,7 @@ import plugins.conflict.{ConflictManager, LatestConflictManager} import plugins.latest.LatestRevisionStrategy import plugins.matcher.PatternMatcher import plugins.parser.m2.PomModuleDescriptorParser -import plugins.resolver.ChainResolver +import plugins.resolver.{ChainResolver, DependencyResolver} import util.{Message, MessageLogger} import scala.xml.NodeSeq @@ -203,9 +203,15 @@ private object IvySbt val mainChain = makeChain("Default", "sbt-chain", resolvers) settings.setDefaultResolver(mainChain.getName) } - private def resolverChain(name: String, resolvers: Seq[Resolver], localOnly: Boolean, settings: IvySettings, log: Logger): ChainResolver = + private def resolverChain(name: String, resolvers: Seq[Resolver], localOnly: Boolean, settings: IvySettings, log: Logger): DependencyResolver = { - val newDefault = new ChainResolver + val newDefault = new ChainResolver { + // Technically, this should be applied to module configurations. + // That would require custom subclasses of all resolver types in ConvertResolver (a delegation approach does not work). + // It would be better to get proper support into Ivy. + override def locate(artifact: IArtifact) = + if(hasImplicitClassifier(artifact)) null else super.locate(artifact) + } newDefault.setName(name) newDefault.setReturnFirst(true) newDefault.setCheckmodified(false) @@ -215,6 +221,14 @@ private object IvySbt } newDefault } + /** A hack to detect if the given artifact is an automatically generated request for a classifier, + * as opposed to a user-initiated declaration. It relies on Ivy prefixing classifier with m:, while sbt uses e:. + * Clearly, it would be better to have an explicit option in Ivy to control this.*/ + def hasImplicitClassifier(artifact: IArtifact): Boolean = + { + import collection.JavaConversions._ + artifact.getQualifiedExtraAttributes.keys.exists(_.asInstanceOf[String] startsWith "m:") + } private def setModuleConfigurations(settings: IvySettings, moduleConfigurations: Seq[ModuleConfiguration]) { val existing = settings.getResolverNames