SQWL#2016 - Project build update
authorTomas Zeman <tomas@functionals.cz>
Tue, 24 Nov 2020 10:49:12 +0100
changeset 30 12cda49d6c84
parent 29 bee7beb443f9
child 31 5c4364d6e726
SQWL#2016 - Project build update
build.sc
mill
--- a/build.sc	Fri Mar 08 16:08:11 2019 +0100
+++ b/build.sc	Tue Nov 24 10:49:12 2020 +0100
@@ -1,16 +1,17 @@
 import ammonite.ops._
 import mill._
+import mill.api.Loose
 import mill.define.{Input, Sources, Target}
 import mill.scalajslib._
 import mill.scalalib._
 import mill.scalalib.publish._
-import mill.util.Loose
 
-val appVersion = "19.03"
+val appVersion = "20.12-SNAPSHOT"
 
-val scalaJsVer = "0.6.25"
-val scalaVer = "2.12.7"
-val akkaVer = "2.4.20"
+val scalaJsVer = "0.6.33"
+val scalaVer = "2.12.12"
+val akkaVer = "2.6.10"
+val akkaHttp = "10.2.1"
 
 trait Common extends ScalaModule with PublishModule {
   val scalaVersion = scalaVer
@@ -19,19 +20,19 @@
 
   def pomSettings = PomSettings(
     description = "Content management system for SQWL",
-    organization = "net.tz",
+    organization = "cz.functionals",
     url = "http://kvalitapracovnihozivota.vubp.cz",
     licenses = Seq(License.`Apache-2.0`),
     versionControl = VersionControl(developerConnection = Some(
-      "ssh://hg@bitbucket.org/tzeman/sqwl-cms")),
+      "ssh://tzeman@hg.functionals.cz/repos/public/sqwl-cms")),
     developers = Seq(
       Developer("tzeman", "Tomas Zeman", "")
     )
   )
 
-  override def artifactName = T{
-    super.artifactName.map(_.flatMap(c =>
-      if (c.isUpper) Seq('-', c.toLower) else Seq(c) ))
+  override def artifactName: Target[String] = T{
+    super.artifactName().flatMap(c =>
+      if (c.isUpper) Seq('-', c.toLower) else Seq(c)).mkString
   }
 
   override def scalacOptions = T{Seq(
@@ -46,19 +47,19 @@
     "-unchecked",                        // Enable additional warnings where generated code depends on assumptions.
     "-Xcheckinit",                       // Wrap field accessors to throw an exception on uninitialized access.
     "-Xfuture",                          // Turn on future language features.
-    "-target:jvm-1.8",
+    "-target:jvm-1.8"
   )}
 
   def hgId: Input[String] = T.input {
-    os.proc("hg", "id", "-i").call().out.string.trim
+    os.proc("hg", "id", "-i").call().out.trim
   }
 
   def hgNum: Input[String] = T.input {
-    os.proc("hg", "id", "-n").call().out.string.trim
+    os.proc("hg", "id", "-n").call().out.trim
   }
 
   def hgTag: Input[Option[String]] = T.input {
-    os.proc("hg", "id", "-t").call().out.string.trim.split(' ').headOption
+    os.proc("hg", "id", "-t").call().out.trim.split(' ').headOption
   }
 
 }
@@ -73,13 +74,14 @@
 object base extends Common with Versions {
   override def scalacPluginIvyDeps: Target[Loose.Agg[Dep]] =
     super.scalacPluginIvyDeps() ++ Agg(
-      ivy"org.scalamacros:::paradise:2.1.0"
+      ivy"org.scalamacros:::paradise:2.1.1"
     )
 
   override def ivyDeps = Agg(
     ivy"com.wacai::config-annotation:0.3.6",
-    ivy"de.heikoseeberger::akka-http-json4s:1.22.0",
+    ivy"com.typesafe.akka::akka-http:$akkaHttp",
     ivy"com.typesafe.akka::akka-slf4j:$akkaVer",
+    ivy"com.typesafe.akka::akka-stream:$akkaVer",
     ivy"org.json4s::json4s-native:3.6.2",
     ivy"ch.qos.logback:logback-classic:1.2.3",
     ivy"com.lihaoyi::scalatags:0.6.7",
@@ -122,8 +124,8 @@
   override def generatedSources: Target[Seq[PathRef]] = T{
     val dir = T.ctx().dest
     val src = contentSources() map(_.path)
-    val ids = src flatMap(ls! _ filter(_.name endsWith ".scalatex") map { p =>
-      val id = p.name replaceAllLiterally (".scalatex", "")
+    val ids = src flatMap(ls! _ filter(_.ext endsWith "scalatex") map { p =>
+      val id = p.last replaceAllLiterally (".scalatex", "")
       val aid = s"article-$id"
       write(dir / s"$id.scala",
         s"""
@@ -139,7 +141,7 @@
           | }
           |
           |/*
-          |${os.read(p).lines mkString "\n"}
+          |${os.read(p)}
           |*/
         """.stripMargin)
       aid
@@ -166,7 +168,7 @@
     Seq(PathRef(dir))
   }
 
-  override def mainClass = Some("sqwl.cms.Main")
+  override def mainClass: T[Option[String]] = Some("sqwl.cms.Main")
 
   override def ivyDeps = Agg(
     ivy"com.beachape::enumeratum:1.5.13"
@@ -196,7 +198,7 @@
     T.sources{ millSourcePath / up / 'production / 'content }
 
   def hgProdId: Input[String] = T.input {
-    os.proc("hg", "id", "-i", "--cwd", "production").call().out.string.trim
+    os.proc("hg", "id", "-i", "--cwd", "production").call().out.trim
   }
 
   override def assemblyName: Target[String] = T{
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mill	Tue Nov 24 10:49:12 2020 +0100
@@ -0,0 +1,48 @@
+#!/usr/bin/env sh
+
+# This is a wrapper script, that automatically download mill from GitHub release pages
+# You can give the required mill version with MILL_VERSION env variable
+# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION
+DEFAULT_MILL_VERSION=0.7.4
+
+set -e
+
+if [ -z "$MILL_VERSION" ] ; then
+  if [ -f ".mill-version" ] ; then
+    MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)"
+  elif [ -f "mill" ] && [ "$BASH_SOURCE" != "mill" ] ; then
+    MILL_VERSION=$(grep -F "DEFAULT_MILL_VERSION=" "mill" | head -n 1 | cut -d= -f2)
+  else
+    MILL_VERSION=$DEFAULT_MILL_VERSION
+  fi
+fi
+
+if [ "x${XDG_CACHE_HOME}" != "x" ] ; then
+  MILL_DOWNLOAD_PATH="${XDG_CACHE_HOME}/mill/download"
+else
+  MILL_DOWNLOAD_PATH="${HOME}/.cache/mill/download"
+fi
+MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/${MILL_VERSION}"
+
+version_remainder="$MILL_VERSION"
+MILL_MAJOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}"
+MILL_MINOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}"
+
+if [ ! -x "$MILL_EXEC_PATH" ] ; then
+  mkdir -p $MILL_DOWNLOAD_PATH
+  if [ "$MILL_MAJOR_VERSION" -gt 0 ] || [ "$MILL_MINOR_VERSION" -ge 5 ] ; then
+    ASSEMBLY="-assembly"
+  fi
+  DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download
+  MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION%%-*}/$MILL_VERSION${ASSEMBLY}"
+  curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL"
+  chmod +x "$DOWNLOAD_FILE"
+  mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH"
+  unset DOWNLOAD_FILE
+  unset MILL_DOWNLOAD_URL
+fi
+
+unset MILL_DOWNLOAD_PATH
+unset MILL_VERSION
+
+exec $MILL_EXEC_PATH "$@"