From d279f2ed76cdea37ea4bba094aa0bad5fa709b5a Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Fri, 13 Sep 2013 16:37:22 -0400 Subject: [PATCH] Move some logic in custom pom parser to separate methods --- ivy/src/main/scala/sbt/CustomPomParser.scala | 21 +++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/ivy/src/main/scala/sbt/CustomPomParser.scala b/ivy/src/main/scala/sbt/CustomPomParser.scala index 277b50900..bb7395aa1 100644 --- a/ivy/src/main/scala/sbt/CustomPomParser.scala +++ b/ivy/src/main/scala/sbt/CustomPomParser.scala @@ -48,12 +48,7 @@ object CustomPomParser def defaultTransform(parser: ModuleDescriptorParser, md: ModuleDescriptor): ModuleDescriptor = { - import collection.JavaConverters._ - // The element of the pom is used to store additional metadata for sbt plugins. - // This is done because the pom XSD does not appear to allow extra metadata anywhere else. - // The pom.xml does not need to be readable by maven because these are only enabled for sbt plugins. - // However, the pom.xml needs to be valid because other tools, like repository managers may read the pom.xml. - val properties = PomModuleDescriptorBuilder.extractPomProperties(md.getExtraInfo).asInstanceOf[java.util.Map[String,String]].asScala.toMap + val properties = getPomProperties(md) // Extracts extra attributes (currently, sbt and Scala versions) stored in the element of the pom. // These are attached to the module itself. @@ -72,12 +67,24 @@ object CustomPomParser // Merges artifact sections for duplicate dependency definitions val mergeDuplicates = IvySbt.hasDuplicateDependencies(md.getDependencies) - val unqualify = (filtered - ExtraAttributesKey) map { case (k,v) => ("e:" + k, v) } + val unqualify = toUnqualify(filtered) if(unqualify.isEmpty && extraDepAttributes.isEmpty && !convertArtifacts && !mergeDuplicates) md else addExtra(unqualify, extraDepAttributes, parser, md) } + // The element of the pom is used to store additional metadata, such as for sbt plugins or for the base URL for API docs. + // This is done because the pom XSD does not appear to allow extra metadata anywhere else. + // The extra sbt plugin metadata in pom.xml does not need to be readable by maven, but the other information may be. + // However, the pom.xml needs to be valid in all cases because other tools like repository managers may read the pom.xml. + private[sbt] def getPomProperties(md: ModuleDescriptor): Map[String,String] = + { + import collection.JavaConverters._ + PomModuleDescriptorBuilder.extractPomProperties(md.getExtraInfo).asInstanceOf[java.util.Map[String,String]].asScala.toMap + } + private[sbt] def toUnqualify(propertyAttributes: Map[String, String]): Map[String, String] = + (propertyAttributes - ExtraAttributesKey) map { case (k,v) => ("e:" + k, v) } + private[this] def artifactExtIncorrect(md: ModuleDescriptor): Boolean = md.getConfigurations.exists(conf => md.getArtifacts(conf.getName).exists(art => JarPackagings(art.getExt))) private[this] def shouldBeUnqualified(m: Map[String, String]): Map[String, String] = m.filterKeys(unqualifiedKeys)