build: publishVersion, cleanup
authorTomas Zeman <tomas@functionals.cz>
Wed, 27 May 2020 17:16:07 +0200
changeset 19 945e8df36800
parent 18 82080374cb75
child 20 cfdd3c439013
build: publishVersion, cleanup
build.sc
--- a/build.sc	Wed May 27 17:08:01 2020 +0200
+++ b/build.sc	Wed May 27 17:16:07 2020 +0200
@@ -18,8 +18,6 @@
 
 trait Common extends CrossSbtModule with PublishModule {
 
-  def publishVersion: Target[String] = V.app
-
   def pomSettings = PomSettings(
     description = "Scalatags DSL for purecss.io framework",
     organization = "functionals.cz",
@@ -50,16 +48,16 @@
   )}
 
   def hgId: Input[String] = T.input {
-    os.proc("hg", "id", "-i").call().out.string.trim
+    os.proc("hg", "id", "-i").call().out.text.trim
   }
 
   def hgNum: Input[String] = T.input {
-    os.proc("hg", "id", "-n").call().out.string.trim
+    os.proc("hg", "id", "-n").call().out.text.trim
   }
 
   private val maskedTags = Set("tip", "qtip", "qbase")
   def hgTag: Input[Option[String]] = T.input {
-    os.proc("hg", "id", "-t").call().out.string.trim.split(' ').filterNot(v =>
+    os.proc("hg", "id", "-t").call().out.text.trim.split(' ').filterNot(v =>
       maskedTags contains v).headOption
   }
 
@@ -69,6 +67,10 @@
     super.sources() :+ PathRef(millSourcePath / 'shared / 'src / 'main / 'scala)
   }
 
+  override def publishVersion: Input[String] = T.input{
+    val tv = hgTag() map(v => "-" + v.replace(".patch", "")) getOrElse ""
+    V.app.replace("SNAPSHOT", s"${hgNum()}-${hgId()}$tv")
+  }
 }
 
 class JvmModule(val crossScalaVersion: String) extends Common