summaryrefslogtreecommitdiff
path: root/scalalib/src/mill/scalalib/publish/Pom.scala
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-12-12 16:56:02 -0800
committerGitHub <noreply@github.com>2018-12-12 16:56:02 -0800
commit9ba4cb69331386dfde9bac69dc2d5b22401face3 (patch)
tree120349e8015ae5717d36bd44209cde6ff9543518 /scalalib/src/mill/scalalib/publish/Pom.scala
parentea7fceb6e56f53bde3517586dfc57e10a605a524 (diff)
downloadmill-9ba4cb69331386dfde9bac69dc2d5b22401face3.tar.gz
mill-9ba4cb69331386dfde9bac69dc2d5b22401face3.tar.bz2
mill-9ba4cb69331386dfde9bac69dc2d5b22401face3.zip
collapse boilerplate folder structure within src/ folders (#505)
* collapse boilerplate folder structure within src/ folders * .
Diffstat (limited to 'scalalib/src/mill/scalalib/publish/Pom.scala')
-rw-r--r--scalalib/src/mill/scalalib/publish/Pom.scala117
1 files changed, 0 insertions, 117 deletions
diff --git a/scalalib/src/mill/scalalib/publish/Pom.scala b/scalalib/src/mill/scalalib/publish/Pom.scala
deleted file mode 100644
index 57a0e196..00000000
--- a/scalalib/src/mill/scalalib/publish/Pom.scala
+++ /dev/null
@@ -1,117 +0,0 @@
-package mill.scalalib.publish
-
-import mill.util.Loose.Agg
-
-import scala.xml.{Atom, Elem, NodeSeq, PrettyPrinter}
-
-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 = {
- val xml =
- <project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
- xmlns ="http://maven.apache.org/POM/4.0.0">
-
- <modelVersion>4.0.0</modelVersion>
- <name>{name}</name>
- <groupId>{artifact.group}</groupId>
- <artifactId>{artifact.id}</artifactId>
- <packaging>jar</packaging>
- <description>{pomSettings.description}</description>
-
- <version>{artifact.version}</version>
- <url>{pomSettings.url}</url>
- <licenses>
- {pomSettings.licenses.map(renderLicense)}
- </licenses>
- <scm>
- { <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)}
- </developers>
- <dependencies>
- {dependencies.map(renderDependency).toSeq}
- </dependencies>
- </project>
-
- val pp = new PrettyPrinter(120, 4)
- head + pp.format(xml)
- }
-
- private def renderLicense(l: License): Elem = {
- <license>
- <name>{l.name}</name>
- <url>{l.url}</url>
- <distribution>{l.distribution}</distribution>
- </license>
- }
-
- private def renderDeveloper(d: Developer): Elem = {
- <developer>
- <id>{d.id}</id>
- <name>{d.name}</name>
- { <organization>{d.organization}</organization>.optional }
- { <organizationUrl>{d.organizationUrl}</organizationUrl>.optional }
- </developer>
- }
-
- private def renderDependency(d: Dependency): Elem = {
- val scope = d.scope match {
- case Scope.Compile => NodeSeq.Empty
- case Scope.Provided => <scope>provided</scope>
- case Scope.Test => <scope>test</scope>
- case Scope.Runtime => <scope>runtime</scope>
- }
- if (d.exclusions.isEmpty)
- <dependency>
- <groupId>{d.artifact.group}</groupId>
- <artifactId>{d.artifact.id}</artifactId>
- <version>{d.artifact.version}</version>
- {scope}
- </dependency>
- else
- <dependency>
- <groupId>{d.artifact.group}</groupId>
- <artifactId>{d.artifact.id}</artifactId>
- <version>{d.artifact.version}</version>
- <exclusions>
- {d.exclusions.map(ex =>
- <exclusion>
- <groupId>{ex._1}</groupId>
- <artifactId>{ex._2}</artifactId>
- </exclusion>
- )}
- </exclusions>
- {scope}
- </dependency>
- }
-
-}