Skip to content
Browse files

Adding McPom

  • Loading branch information...
1 parent af48409 commit 92a1fc94dc91b178dbb65c0814e3cb0c50383335 @viktorklang viktorklang committed Dec 8, 2010
Showing with 54 additions and 2 deletions.
  1. +54 −2 project/build/AkkaProject.scala
View
56 project/build/AkkaProject.scala
@@ -704,7 +704,7 @@ class AkkaModulesParentProject(info: ProjectInfo) extends DefaultProject(info) {
"*;version=0.0.0")
}
- class AkkaOSGiAssemblyProject(info: ProjectInfo) extends DefaultProject(info) {
+ class AkkaOSGiAssemblyProject(info: ProjectInfo) extends DefaultProject(info) with McPom {
override def disableCrossPaths = true
// Akka bundles
@@ -743,6 +743,9 @@ class AkkaModulesParentProject(info: ProjectInfo) extends DefaultProject(info) {
val jms_1_1 = "org.apache.geronimo.specs" % "geronimo-jms_1.1_spec" % "1.1.1" % "compile" intransitive
val joda = "joda-time" % "joda-time" % "1.6" intransitive
+ override def pomPostProcess(node: scala.xml.Node): scala.xml.Node = mcPom(AkkaModulesParentProject.this.moduleConfigurations)(super.pomPostProcess(node))
+
+
override def packageAction =
task {
val libs: Seq[Path] = managedClasspath(config("compile")).get.toSeq
@@ -874,7 +877,7 @@ class AkkaModulesParentProject(info: ProjectInfo) extends DefaultProject(info) {
lazy val stressTestsEnabled = systemOptional[Boolean]("stress.tests",false)
// ------------------------------------------------------------
- class AkkaModulesDefaultProject(info: ProjectInfo, val deployPath: Path) extends DefaultProject(info) with DeployProject with OSGiProject {
+ class AkkaModulesDefaultProject(info: ProjectInfo, val deployPath: Path) extends DefaultProject(info) with DeployProject with OSGiProject with McPom {
override def disableCrossPaths = true
lazy val sourceArtifact = Artifact(this.artifactID, "source", "jar", Some("sources"), Nil, None)
lazy val docsArtifact = Artifact(this.artifactID, "doc", "jar", Some("docs"), Nil, None)
@@ -883,6 +886,8 @@ class AkkaModulesParentProject(info: ProjectInfo) extends DefaultProject(info) {
override def packageDocsJar = this.defaultJarPath("-docs.jar")
override def packageSrcJar = this.defaultJarPath("-sources.jar")
override def packageToPublishActions = super.packageToPublishActions ++ Seq(this.packageDocs, this.packageSrc)
+ override def pomPostProcess(node: scala.xml.Node): scala.xml.Node = mcPom(AkkaModulesParentProject.this.moduleConfigurations)(super.pomPostProcess(node))
+
/**
* Used for testOptions, possibility to enable the running of integration and or stresstests
@@ -924,3 +929,50 @@ trait DeployProject { self: BasicScalaProject =>
trait OSGiProject extends BNDPlugin { self: DefaultProject =>
override def bndExportPackage = Seq("akka.*;version=%s".format(projectVersion.value))
}
+
+
+trait McPom { self: DefaultProject =>
+ import scala.xml._
+
+ def mcPom(mcs: Set[ModuleConfiguration])(node: Node): Node = {
+
+ def cleanUrl(url: String) = url match {
+ case null => ""
+ case "" => ""
+ case u if u endsWith "/" => u
+ case u => u + "/"
+ }
+
+ val oldRepos = (node \\ "project" \ "repositories" \ "repository").
+ map( n => cleanUrl((n \ "url").text) -> (n \ "name").text).toList
+ val newRepos = mcs.filter(_.resolver.isInstanceOf[MavenRepository]).map(m => {
+ val r = m.resolver.asInstanceOf[MavenRepository]
+ cleanUrl(r.root) -> r.name
+ })
+
+ val repos = Map((oldRepos ++ newRepos):_*).map( pair =>
+ <repository>
+ <id>{pair._2.toSeq.filter(_.isLetterOrDigit).mkString}</id>
+ <name>{pair._2}</name>
+ <url>{pair._1}</url>
+ </repository>
+ )
+
+ 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] = if ((node \\ "project" \ "repositories" ).isEmpty) {
+ case Elem(prefix, "project", attribs, scope, children @ _*) =>
+ Elem(prefix, "project", attribs, scope, children ++ <repositories>{repos}</repositories>:_*)
+ } else {
+ case Elem(prefix, "repositories", attribs, scope, children @ _*) =>
+ Elem(prefix, "repositories", attribs, scope, repos.toList:_*)
+ }
+
+ rewrite(rule)(node.theSeq)(0)
+ }
+}

0 comments on commit 92a1fc9

Please sign in to comment.
Something went wrong with that request. Please try again.