diff options
author | Nikolay Tatarinov <5min4eq.unity@gmail.com> | 2018-03-06 10:22:01 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-06 10:22:01 +0300 |
commit | 8ac53668af0ff6ea699e5d99105bd74585057bf1 (patch) | |
tree | c582013b385f73565cd185012b5cafcee544c47c /scalalib/src | |
parent | d4a00892f9c9c43e3d0f6906482b27e04d79d8dc (diff) | |
download | mill-8ac53668af0ff6ea699e5d99105bd74585057bf1.tar.gz mill-8ac53668af0ff6ea699e5d99105bd74585057bf1.tar.bz2 mill-8ac53668af0ff6ea699e5d99105bd74585057bf1.zip |
fix optional xml tags in POM (#198)
Diffstat (limited to 'scalalib/src')
-rw-r--r-- | scalalib/src/mill/scalalib/publish/Pom.scala | 55 |
1 files changed, 23 insertions, 32 deletions
diff --git a/scalalib/src/mill/scalalib/publish/Pom.scala b/scalalib/src/mill/scalalib/publish/Pom.scala index 382db56a..1a86e7de 100644 --- a/scalalib/src/mill/scalalib/publish/Pom.scala +++ b/scalalib/src/mill/scalalib/publish/Pom.scala @@ -8,29 +8,28 @@ object Pom { val head = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + implicit class XmlOps(val e: Elem) extends AnyVal { + // source: https://stackoverflow.com/a/5254068/449071 + def optional : 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 + } + } + } + //TODO - not only jar packaging support? def apply(artifact: Artifact, 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" @@ -50,10 +49,10 @@ object Pom { {pomSettings.licenses.map(renderLicense)} </licenses> <scm> - <connection>{pomSettings.versionControl.connection}</connection>.optionnal - <developerConnection>{pomSettings.versionControl.developerConnection}</developerConnection>.optionnal - <tag>{pomSettings.versionControl.tag}</tag>.optionnal - <url>{pomSettings.versionControl.browsableRepository}</url>.optionnal + { <connection>{pomSettings.versionControl.connection}</connection>.optional } + { <developerConnection>{pomSettings.versionControl.developerConnection}</developerConnection>.optional } + { <tag>{pomSettings.versionControl.tag}</tag>.optional } + { <url>{pomSettings.versionControl.browsableRepository}</url>.optional } </scm> <developers> {pomSettings.developers.map(renderDeveloper)} @@ -79,16 +78,8 @@ object Pom { <developer> <id>{d.id}</id> <name>{d.name}</name> - { - d.organization.map { org => - <organization>{org}</organization> - }.getOrElse(NodeSeq.Empty) - } - { - d.organizationUrl.map { orgUrl => - <organizationUrl>{orgUrl}</organizationUrl> - }.getOrElse(NodeSeq.Empty) - } + { <organization>{d.organization}</organization>.optional } + { <organizationUrl>{d.organizationUrl}</organizationUrl>.optional } </developer> } |