diff --git a/project/Sbt.scala b/project/Sbt.scala index 845da8623..3cee103b0 100644 --- a/project/Sbt.scala +++ b/project/Sbt.scala @@ -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", diff --git a/project/Util.scala b/project/Util.scala index fd599ef9a..6ea6fe263 100644 --- a/project/Util.scala +++ b/project/Util.scala @@ -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 } -} \ No newline at end of file +}