summaryrefslogtreecommitdiff
path: root/scalalib/src/mill/scalalib/publish/Pom.scala
diff options
context:
space:
mode:
authorGuillaume Massé <masgui@gmail.com>2018-03-01 05:28:48 +0100
committerLi Haoyi <haoyi.sg@gmail.com>2018-02-28 20:28:48 -0800
commita6bd3dbe0f9f6d58326f0ffaa0737d07d5a3821f (patch)
tree3defba186bc48369269eb618cbca3802ea7bab1e /scalalib/src/mill/scalalib/publish/Pom.scala
parentc7b2fff6badcc595c177f85c7331cc4868c73412 (diff)
downloadmill-a6bd3dbe0f9f6d58326f0ffaa0737d07d5a3821f.tar.gz
mill-a6bd3dbe0f9f6d58326f0ffaa0737d07d5a3821f.tar.bz2
mill-a6bd3dbe0f9f6d58326f0ffaa0737d07d5a3821f.zip
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.
Diffstat (limited to 'scalalib/src/mill/scalalib/publish/Pom.scala')
-rw-r--r--scalalib/src/mill/scalalib/publish/Pom.scala26
1 files changed, 23 insertions, 3 deletions
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 =
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
@@ -32,8 +50,10 @@ object Pom {
{pomSettings.licenses.map(renderLicense)}
</licenses>
<scm>
- <url>{pomSettings.scm.url}</url>
- <connection>{pomSettings.scm.connection}</connection>
+ <connection>{pomSettings.versionControl.connection}</connection>.optionnal
+ <developerConnection>{pomSettings.versionControl.developerConnection}</developerConnection>.optionnal
+ <tag>{pomSettings.versionControl.tag}</tag>.optionnal
+ <url>{pomSettings.versionControl.browsableRepository}</url>.optionnal
</scm>
<developers>
{pomSettings.developers.map(renderDeveloper)}