From a6bd3dbe0f9f6d58326f0ffaa0737d07d5a3821f Mon Sep 17 00:00:00 2001 From: Guillaume Massé Date: Thu, 1 Mar 2018 05:28:48 +0100 Subject: Add dsl for SCM (now called VersionControl) (#168) The scm url syntax is a source of confusion for developper. I added VersionControl.github() to simplify this process. We can add other common VersionControl url scheme like Bazar, etc. --- scalalib/src/mill/scalalib/publish/Pom.scala | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'scalalib/src/mill/scalalib/publish/Pom.scala') diff --git a/scalalib/src/mill/scalalib/publish/Pom.scala b/scalalib/src/mill/scalalib/publish/Pom.scala index 895e1686..382db56a 100644 --- a/scalalib/src/mill/scalalib/publish/Pom.scala +++ b/scalalib/src/mill/scalalib/publish/Pom.scala @@ -2,7 +2,7 @@ package mill.scalalib.publish import mill.util.Loose.Agg -import scala.xml.{Elem, NodeSeq, PrettyPrinter} +import scala.xml.{Atom, Elem, NodeSeq, PrettyPrinter} object Pom { @@ -13,6 +13,24 @@ object Pom { dependencies: Agg[Dependency], name: String, pomSettings: PomSettings): String = { + + // source: https://stackoverflow.com/a/5254068/449071 + implicit def optionElem(e: Elem) = new { + def optionnal : NodeSeq = { + require(e.child.length == 1) + e.child.head match { + case atom: Atom[Option[_]] => atom.data match { + case None => NodeSeq.Empty + case Some(x) => e.copy(child = x match { + case n: NodeSeq => n + case x => new Atom(x) + }) + } + case _ => e + } + } + } + val xml = - {pomSettings.scm.url} - {pomSettings.scm.connection} + {pomSettings.versionControl.connection}.optionnal + {pomSettings.versionControl.developerConnection}.optionnal + {pomSettings.versionControl.tag}.optionnal + {pomSettings.versionControl.browsableRepository}.optionnal {pomSettings.developers.map(renderDeveloper)} -- cgit v1.2.3