build.sc: hg info -> assembly name
authorTomas Zeman <tzeman@volny.cz>
Tue, 08 Jan 2019 12:28:53 +0100
changeset 26 4978df5ebf0a
parent 25 da897e7419e7
child 27 8529ce302f7c
build.sc: hg info -> assembly name
build.sc
--- a/build.sc	Thu Jan 03 13:32:19 2019 +0100
+++ b/build.sc	Tue Jan 08 12:28:53 2019 +0100
@@ -6,7 +6,7 @@
 import mill.scalalib.publish._
 import mill.util.Loose
 
-val appVersion = "18.12"
+val appVersion = "19.01-SNAPSHOT"
 
 val scalaJsVer = "0.6.25"
 val scalaVer = "2.12.7"
@@ -52,6 +52,15 @@
   def hgId: Input[String] = T.input {
     os.proc("hg", "id", "-i").call().out.string.trim
   }
+
+  def hgNum: Input[String] = T.input {
+    os.proc("hg", "id", "-n").call().out.string.trim
+  }
+
+  def hgTag: Input[Option[String]] = T.input {
+    os.proc("hg", "id", "-t").call().out.string.trim.split(' ').headOption
+  }
+
 }
 
 trait Versions {
@@ -162,6 +171,19 @@
   override def ivyDeps = Agg(
     ivy"com.beachape::enumeratum:1.5.13"
   )
+
+  def assemblyName: Target[String] = T{
+    val tg = hgTag().map(v => s"-${v.replace(".patch", "")}") getOrElse ""
+    val ver = publishVersion().replace("SNAPSHOT", s"${hgNum()}-${hgId()}$tg")
+    s"cms-$ver"
+  }
+
+  override def assembly: Target[PathRef] = T{
+    val out = T.ctx().dest / s"${assemblyName()}.jar"
+    os.move(super.assembly().path, out)
+    PathRef(out)
+  }
+
 }
 
 object example extends Content {
@@ -172,6 +194,14 @@
 object production extends Content {
   def contentSources: Sources =
     T.sources{ millSourcePath / up / 'production / 'content }
+
+  def hgProdId: Input[String] = T.input {
+    os.proc("hg", "id", "-i", "--cwd", "production").call().out.string.trim
+  }
+
+  override def assemblyName: Target[String] = T{
+    s"${super.assemblyName()}-${hgProdId()}"
+  }
 }