mirror of https://github.com/sbt/sbt.git
Merge pull request #222 from jberkel/0.11
Added support for <classifier> in makePom
This commit is contained in:
commit
cd8ff08940
|
|
@ -132,6 +132,7 @@ class MakePom(val log: Logger)
|
|||
<artifactId>{mrid.getName}</artifactId>
|
||||
<version>{mrid.getRevision}</version>
|
||||
{ scopeAndOptional(dependency) }
|
||||
{ classifier(dependency) }
|
||||
{
|
||||
val (warns, excls) = List.separate(excl.map(makeExclusion))
|
||||
if(!warns.isEmpty) log.warn(warns.mkString(IO.Newline))
|
||||
|
|
@ -144,6 +145,13 @@ class MakePom(val log: Logger)
|
|||
</dependency>
|
||||
}
|
||||
|
||||
def classifier(dependency: DependencyDescriptor): Seq[scala.xml.Node] =
|
||||
{
|
||||
for (da <- dependency.getAllDependencyArtifacts;
|
||||
cl <- Option(da.getExtraAttribute("classifier"))) yield
|
||||
<classifier>{cl}</classifier>
|
||||
}
|
||||
|
||||
def scopeAndOptional(dependency: DependencyDescriptor): NodeSeq =
|
||||
{
|
||||
val (scope, opt) = getScopeAndOptional(dependency.getModuleConfigurations)
|
||||
|
|
@ -238,4 +246,4 @@ class MakePom(val log: Logger)
|
|||
}
|
||||
module.getDependencies flatMap translate
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ object PomTest extends Build
|
|||
"d" % "d" % "1.0" % "test",
|
||||
"e" % "e" % "1.0" % "custom",
|
||||
"f" % "f" % "1.0" % "custom,optional,runtime",
|
||||
"g" % "g" % "1.0" % "custom,runtime"
|
||||
"g" % "g" % "1.0" % "custom,runtime" classifier "foo"
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -21,17 +21,17 @@ object PomTest extends Build
|
|||
|
||||
def checkPom = makePom map { pom =>
|
||||
val expected = Seq(
|
||||
("a", Some("compile"), false),
|
||||
("b", Some("runtime"), true),
|
||||
("c", None, true),
|
||||
("d", Some("test"), false),
|
||||
("e", Some("custom"), false),
|
||||
("f", Some("runtime"), true),
|
||||
("g", Some("runtime"), false)
|
||||
("a", Some("compile"), false, None),
|
||||
("b", Some("runtime"), true, None),
|
||||
("c", None, true, None),
|
||||
("d", Some("test"), false, None),
|
||||
("e", Some("custom"), false, None),
|
||||
("f", Some("runtime"), true, None),
|
||||
("g", Some("runtime"), false, Some("foo"))
|
||||
)
|
||||
val loaded = xml.XML.loadFile(pom)
|
||||
val deps = loaded \\ "dependency"
|
||||
expected foreach { case (id, scope, opt) =>
|
||||
expected foreach { case (id, scope, opt, classifier) =>
|
||||
val dep = deps.find(d => (d \ "artifactId").text == id).getOrElse( error("Dependency '" + id + "' not written to pom:\n" + loaded))
|
||||
|
||||
val actualOpt = java.lang.Boolean.parseBoolean( (dep \\ "optional").text )
|
||||
|
|
@ -39,7 +39,9 @@ object PomTest extends Build
|
|||
assert(opt == actualOpt, "Invalid 'optional' section '" + (dep \\ "optional") + "', expected optional=" + opt)
|
||||
|
||||
val actualScope = (dep \\ "scope") match { case Seq() => None; case x => Some(x.text) }
|
||||
val acutalClassifier = (dep \\ "classifier") match { case Seq() => None; case x => Some(x.text) }
|
||||
assert(actualScope == scope, "Invalid 'scope' section '" + (dep \\ "scope") + "', expected scope=" + scope)
|
||||
assert(acutalClassifier == classifier, "Invalid 'classifier' section '" + (dep \\ "classifier") + "', expected classifier=" + classifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue