mirror of https://github.com/sbt/sbt.git
Add warning to MakePom for intransitive dependencies.
Intransitive does not work in Maven, and does not translate to pom.xml.
This commit is contained in:
parent
efa6041103
commit
9beff22d9a
|
|
@ -236,21 +236,30 @@ class MakePom(val log: Logger) {
|
||||||
def makeDependency(dependency: DependencyDescriptor, includeTypes: Set[String]): NodeSeq =
|
def makeDependency(dependency: DependencyDescriptor, includeTypes: Set[String]): NodeSeq =
|
||||||
makeDependency(dependency, includeTypes, Nil)
|
makeDependency(dependency, includeTypes, Nil)
|
||||||
|
|
||||||
def makeDependency(dependency: DependencyDescriptor, includeTypes: Set[String], excludes: Seq[ExcludeRule]): NodeSeq =
|
def makeDependency(dependency: DependencyDescriptor, includeTypes: Set[String], excludes: Seq[ExcludeRule]): NodeSeq = {
|
||||||
{
|
def warnIntransitve(): Unit =
|
||||||
val artifacts = dependency.getAllDependencyArtifacts
|
if (!dependency.isTransitive)
|
||||||
val includeArtifacts = artifacts.filter(d => includeTypes(d.getType))
|
log.warn(
|
||||||
if (artifacts.isEmpty) {
|
s"""Translating intransitive dependency (${dependency.getDependencyId}) into pom.xml, but maven does not support intransitive dependencies.
|
||||||
val configs = dependency.getModuleConfigurations
|
| Please use exclusions instead so transitive dependencies will be correctly excluded in dependent projects.
|
||||||
if (configs.filterNot(Set("sources", "docs")).nonEmpty) {
|
""".stripMargin)
|
||||||
val (scope, optional) = getScopeAndOptional(dependency.getModuleConfigurations)
|
else ()
|
||||||
makeDependencyElem(dependency, scope, optional, None, None, excludes)
|
val artifacts = dependency.getAllDependencyArtifacts
|
||||||
} else NodeSeq.Empty
|
val includeArtifacts = artifacts.filter(d => includeTypes(d.getType))
|
||||||
} else if (includeArtifacts.isEmpty)
|
if (artifacts.isEmpty) {
|
||||||
NodeSeq.Empty
|
val configs = dependency.getModuleConfigurations
|
||||||
else
|
if (configs.filterNot(Set("sources", "docs")).nonEmpty) {
|
||||||
NodeSeq.fromSeq(artifacts.flatMap(a => makeDependencyElem(dependency, a, excludes)))
|
warnIntransitve()
|
||||||
|
val (scope, optional) = getScopeAndOptional(dependency.getModuleConfigurations)
|
||||||
|
makeDependencyElem(dependency, scope, optional, None, None, excludes)
|
||||||
|
} else NodeSeq.Empty
|
||||||
|
} else if (includeArtifacts.isEmpty) {
|
||||||
|
NodeSeq.Empty
|
||||||
|
} else {
|
||||||
|
warnIntransitve()
|
||||||
|
NodeSeq.fromSeq(artifacts.flatMap(a => makeDependencyElem(dependency, a, excludes)))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@deprecated("Use `makeDependencyElem` variant which takes excludes", "0.13.9")
|
@deprecated("Use `makeDependencyElem` variant which takes excludes", "0.13.9")
|
||||||
def makeDependencyElem(dependency: DependencyDescriptor, artifact: DependencyArtifactDescriptor): Option[Elem] =
|
def makeDependencyElem(dependency: DependencyDescriptor, artifact: DependencyArtifactDescriptor): Option[Elem] =
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
[@jsuereth]: http://github.com/jsuereth
|
||||||
|
|
||||||
|
### Fixes with compatibility implications
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
- makePom now warns when it sees intransitive dependencies, which do not translate to Maven. by [@jsuereth][@jsuereth]
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
scalaVersion := "2.10.2"
|
scalaVersion := "2.10.2"
|
||||||
|
|
||||||
libraryDependencies += "org.scala-sbt" %% "sbinary" % "0.4.1" withSources() withJavadoc()
|
libraryDependencies += "org.scala-sbt" %% "sbinary" % "0.4.1" withSources() withJavadoc()
|
||||||
|
libraryDependencies += "org.scala-sbt" % "io" % "0.13.8" intransitive()
|
||||||
|
|
||||||
lazy val checkPom = taskKey[Unit]("check pom to ensure no <type> sections are generated")
|
lazy val checkPom = taskKey[Unit]("check pom to ensure no <type> sections are generated")
|
||||||
|
|
||||||
|
|
@ -8,6 +9,12 @@ checkPom := {
|
||||||
val pomFile = makePom.value
|
val pomFile = makePom.value
|
||||||
val pom = xml.XML.loadFile(pomFile)
|
val pom = xml.XML.loadFile(pomFile)
|
||||||
val tpe = pom \\ "type"
|
val tpe = pom \\ "type"
|
||||||
if(tpe.nonEmpty)
|
if(tpe.nonEmpty) {
|
||||||
error("Expected no <type> sections, got: " + tpe + " in \n\n" + pom)
|
sys.error("Expected no <type> sections, got: " + tpe + " in \n\n" + pom)
|
||||||
|
}
|
||||||
|
val dir = (streams in makePom).value.cacheDirectory / "out"
|
||||||
|
System.out.println(dir.getAbsolutePath)
|
||||||
|
val lines = IO.readLines(dir)
|
||||||
|
val hasError = lines exists { line => line contains "Translating intransitive dependency "}
|
||||||
|
assert(hasError, s"Failed to detect intransitive dependencies, got: ${lines.mkString("\n")}")
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue