Skip to content

Commit

Permalink
Add post pom processor to make sure that casbah dependency in pom gen…
Browse files Browse the repository at this point in the history
…erated for salat-core specifies type "pom" - otherwise sbt is fine but Maven proper will fail with an error trying to download a jar for an aggregator pom.
  • Loading branch information
rktoomey committed Jul 8, 2012
1 parent 7a62537 commit 1ac5819
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion project/SalatBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ object Publish {
pomIncludeRepository := { _ => false },
licenses := Seq("Apache 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
homepage := Some(url("https://github.com/novus/salat")),
pomPostProcess := {
(pomXML: scala.xml.Node) =>
PomPostProcessor(pomXML)
},
pomExtra := (
<scm>
<url>git://github.com/novus/salat.git</url>
Expand All @@ -118,13 +122,40 @@ object Publish {
)
}

object PomPostProcessor {
import scala.xml._

// see https://groups.google.com/d/topic/simple-build-tool/pox4BwWshtg/discussion
// adding a post pom processor to make sure that pom for salat-core correctly specifies depdency type pom for casbah dependency

def apply(pomXML: Node): Node = {
def rewrite(pf: PartialFunction[Node, Node])(ns: Seq[Node]): Seq[Node] = for (subnode <- ns) yield subnode match {
case e: Elem =>
if (pf isDefinedAt e) pf(e)
else Elem(e.prefix, e.label, e.attributes, e.scope, rewrite(pf)(e.child): _*)
case other => other
}

val rule: PartialFunction[Node, Node] = {
case e @ Elem(prefix, "dependency", attribs, scope, children @ _*) => {
if (children.contains(<groupId>org.mongodb</groupId>)) {
Elem(prefix, "dependency", attribs, scope, children ++ <type>pom</type>: _*)
}
else e
}
}

rewrite(rule)(pomXML.theSeq)(0)
}
}

object Dependencies {
val specs2 = "org.specs2" %% "specs2" % "1.11" % "test"
val commonsLang = "commons-lang" % "commons-lang" % "2.5" % "test"
val slf4jApi = "org.slf4j" % "slf4j-api" % "1.6.4"
val logbackCore = "ch.qos.logback" % "logback-core" % "1.0.0" % "test"
val logbackClassic = "ch.qos.logback" % "logback-classic" % "1.0.0" % "test"
val casbah = "org.mongodb" %% "casbah" % "2.4.1"
val casbah = "org.mongodb" %% "casbah" % "2.4.1" artifacts( Artifact("casbah", "pom", "pom") )
val lift_json = "net.liftweb" %% "lift-json" % "2.5-SNAPSHOT"
}

Expand Down

0 comments on commit 1ac5819

Please sign in to comment.