From 1cb63c84e128c12ed52bad2eea454730498e4c06 Mon Sep 17 00:00:00 2001 From: Antonio Cunei Date: Wed, 20 May 2015 03:26:30 +0200 Subject: [PATCH 1/2] Do not emit in the pom dependencies that are only sources or docs The pom generation code tries its best to map Ivy's configurations to Maven scopes; however, sources and javadoc artifacts cannot be properly mapped and they currently are emitted as dependencies in the default scope (compile). That may lead to the source/doc jars being erroneously processed like regular jars by automated tools. Arguably, the source/docs jars should not be included in the pom file as dependencies at all. This commit filters out the dependencies that only appear in the sources and/or javadoc Ivy configurations, thereby preventing them from appearing in the final pom file. --- ivy/src/main/scala/sbt/MakePom.scala | 29 ++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/ivy/src/main/scala/sbt/MakePom.scala b/ivy/src/main/scala/sbt/MakePom.scala index d0e1a2741..16bd6002a 100644 --- a/ivy/src/main/scala/sbt/MakePom.scala +++ b/ivy/src/main/scala/sbt/MakePom.scala @@ -233,28 +233,33 @@ class MakePom(val log: Logger) { val artifacts = dependency.getAllDependencyArtifacts val includeArtifacts = artifacts.filter(d => includeTypes(d.getType)) if (artifacts.isEmpty) { - val (scope, optional) = getScopeAndOptional(dependency.getModuleConfigurations) - makeDependencyElem(dependency, scope, optional, None, None) + val configs = dependency.getModuleConfigurations + if (configs.filterNot(Set("sources","docs")).nonEmpty) { + val (scope, optional) = getScopeAndOptional(dependency.getModuleConfigurations) + makeDependencyElem(dependency, scope, optional, None, None) + } else NodeSeq.Empty } else if (includeArtifacts.isEmpty) NodeSeq.Empty else - NodeSeq.fromSeq(artifacts.map(a => makeDependencyElem(dependency, a))) + NodeSeq.fromSeq(artifacts.flatMap(a => makeDependencyElem(dependency, a))) } - def makeDependencyElem(dependency: DependencyDescriptor, artifact: DependencyArtifactDescriptor): Elem = + def makeDependencyElem(dependency: DependencyDescriptor, artifact: DependencyArtifactDescriptor): Option[Elem] = { val configs = artifact.getConfigurations.toList match { case Nil | "*" :: Nil => dependency.getModuleConfigurations case x => x.toArray } - val (scope, optional) = getScopeAndOptional(configs) - 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) + if (configs.filterNot(Set("sources","docs")).nonEmpty) { + val (scope, optional) = getScopeAndOptional(configs) + 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 + } + Some(makeDependencyElem(dependency, scope, optional, classifier, tpe)) + } else None } def makeDependencyElem(dependency: DependencyDescriptor, scope: Option[String], optional: Boolean, classifier: Option[String], tpe: Option[String]): Elem = { From d14afcf67d43101590f963480aa981cf8dd3eded Mon Sep 17 00:00:00 2001 From: Antonio Cunei Date: Tue, 26 May 2015 23:48:05 +0200 Subject: [PATCH 2/2] Adding notes for 2001/2027 --- notes/0.13.9/source-pom.markdown | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 notes/0.13.9/source-pom.markdown diff --git a/notes/0.13.9/source-pom.markdown b/notes/0.13.9/source-pom.markdown new file mode 100644 index 000000000..fa906e711 --- /dev/null +++ b/notes/0.13.9/source-pom.markdown @@ -0,0 +1,21 @@ + + [@cunei]: http://github.com/cunei + [2001]: https://github.com/sbt/sbt/issues/2001 + [2027]: https://github.com/sbt/sbt/pull/2027 + +### Fixes with compatibility implications + +- Starting with 0.13.9, the generated POM files no longer include dependencies on source or javadoc jars + obtained via withSources() or withJavadoc() + +### Improvements + +### Bug fixes + +### POM files no longer include certain source and javadoc jars + +When declaring library dependencies using the withSources() or withJavadoc() options, sbt was also including +in the pom file, as dependencies, the source or javadoc jars using the default Maven scope. Such dependencies +might be erroneously processed as they were regular jars by automated tools + +[#2001][2001]/[#2027][2027] by [@cunei][@cunei]