Publish poms for maven friendliness

This allows an artifactory virtual repo to serve sbt maven-style
This commit is contained in:
Peter Vlugter 2012-04-05 15:05:13 +12:00
parent 602e5e2f27
commit 0b1297d65f
2 changed files with 27 additions and 3 deletions

View File

@ -165,7 +165,7 @@ object Sbt extends Build
import Sxr.sxr
def releaseSettings = Release.settings(nonRoots, proguard in Proguard)
def rootSettings = releaseSettings ++ LaunchProguard.settings ++ LaunchProguard.specific(launchSub) ++ Sxr.settings ++ docSetting ++ Seq(
def rootSettings = releaseSettings ++ LaunchProguard.settings ++ LaunchProguard.specific(launchSub) ++ Sxr.settings ++ docSetting ++ Util.publishPomSettings ++ Seq(
scriptedScalaVersion <<= scalaVersion.identity,
scripted <<= scriptedTask,
scriptedSource <<= (sourceDirectory in sbtSub) / "sbt-test",

View File

@ -20,7 +20,7 @@ object Util
def noPublish(p: Project) = p.copy(settings = noRemotePublish(p.settings))
def noRemotePublish(in: Seq[Setting[_]]) = in filterNot { s => s.key == deliver || s.key == publish }
def project(path: File, nameString: String) = Project(normalize(nameString), path) settings( name := nameString )
def project(path: File, nameString: String) = Project(normalize(nameString), path) settings( Seq(name := nameString) ++ publishPomSettings : _* )
def baseProject(path: File, nameString: String) = project(path, nameString) settings( base : _*)
def testedBaseProject(path: File, nameString: String) = baseProject(path, nameString) settings( testDependencies : _*)
@ -71,6 +71,30 @@ object Util
}
def binID = "compiler-interface-bin"
def srcID = "compiler-interface-src"
def publishPomSettings: Seq[Setting[_]] = Seq(
publishArtifact in makePom := true,
pomPostProcess := cleanPom _
)
def cleanPom(pomNode: scala.xml.Node) =
{
import scala.xml._
def cleanNodes(nodes: Seq[Node]): Seq[Node] = nodes flatMap ( _ match {
case elem @ Elem(prefix, "dependency", attributes, scope, children @ _*) if excludePomDependency(elem) =>
NodeSeq.Empty
case Elem(prefix, "classifier", attributes, scope, children @ _*) =>
NodeSeq.Empty
case Elem(prefix, label, attributes, scope, children @ _*) =>
Elem(prefix, label, attributes, scope, cleanNodes(children): _*).theSeq
case other => other
})
cleanNodes(pomNode.theSeq)(0)
}
def excludePomDependency(node: scala.xml.Node) = node \ "artifactId" exists { n => excludePomArtifact(n.text) }
def excludePomArtifact(artifactId: String) = (artifactId == "compiler-interface") || (artifactId startsWith "precompiled")
}
object Common
{
@ -101,4 +125,4 @@ object Licensed
if(!note.exists) Nil else
try { seePaths(base, IO.read(note)) }
catch { case e: Exception => s.log.warn("Could not read NOTICE"); Nil }
}
}