From 77ed899a962da7c6a45a34eb0eafb1417674d28b Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Wed, 2 Oct 2013 19:39:17 -0400 Subject: [PATCH] 'makePom' should not generate elements for standard classifiers. Fixes #728. The element was generated for any explicit Artifact with a type other than "jar". withSources() and withJavadoc() create explicit Artifacts of this kind, but shouldn't have elements. They are primarily artifacts with classifiers- the type is an Ivy aspect. So, when writing to a pom, don't use write a type for known classifiers. --- ivy/src/main/scala/sbt/MakePom.scala | 8 +++++++- .../dependency-management/pom-type/build.sbt | 13 +++++++++++++ .../sbt-test/dependency-management/pom-type/test | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 sbt/src/sbt-test/dependency-management/pom-type/build.sbt create mode 100644 sbt/src/sbt-test/dependency-management/pom-type/test diff --git a/ivy/src/main/scala/sbt/MakePom.scala b/ivy/src/main/scala/sbt/MakePom.scala index cbfb0a5a1..5e49243d3 100644 --- a/ivy/src/main/scala/sbt/MakePom.scala +++ b/ivy/src/main/scala/sbt/MakePom.scala @@ -174,7 +174,13 @@ class MakePom(val log: Logger) case x => x.toArray } val (scope, optional) = getScopeAndOptional(configs) - makeDependencyElem(dependency, scope, optional, artifactClassifier(artifact), artifactType(artifact)) + val classifier = artifactClassifier(artifact) + val baseType = artifactType(artifact) + val tpe = (classifier, baseType) match { + case (Some(c), Some(tpe)) if Artifact.classifierType(c) == tpe => None + case _ => baseType + } + makeDependencyElem(dependency, scope, optional, classifier, tpe) } def makeDependencyElem(dependency: DependencyDescriptor, scope: Option[String], optional: Boolean, classifier: Option[String], tpe: Option[String]): Elem = { diff --git a/sbt/src/sbt-test/dependency-management/pom-type/build.sbt b/sbt/src/sbt-test/dependency-management/pom-type/build.sbt new file mode 100644 index 000000000..e06101113 --- /dev/null +++ b/sbt/src/sbt-test/dependency-management/pom-type/build.sbt @@ -0,0 +1,13 @@ +scalaVersion := "2.10.2" + +libraryDependencies += "org.scala-sbt" %% "sbinary" % "0.4.1" withSources() withJavadoc() + +lazy val checkPom = taskKey[Unit]("check pom to ensure no sections are generated") + +checkPom := { + val pomFile = makePom.value + val pom = xml.XML.loadFile(pomFile) + val tpe = pom \\ "type" + if(!tpe.isEmpty) + error("Expected no sections, got: " + tpe + " in \n\n" + pom) +} \ No newline at end of file diff --git a/sbt/src/sbt-test/dependency-management/pom-type/test b/sbt/src/sbt-test/dependency-management/pom-type/test new file mode 100644 index 000000000..0e9f0f7b6 --- /dev/null +++ b/sbt/src/sbt-test/dependency-management/pom-type/test @@ -0,0 +1 @@ +> checkPom \ No newline at end of file