Build refactoring: sbt -> mill
authorTomas Zeman <tzeman@volny.cz>
Thu, 17 Jan 2019 14:51:59 +0100
changeset 20 529418651908
parent 19 34d3cc40552c
child 21 175e7d7ce5b3
Build refactoring: sbt -> mill
.hgignore
build.sbt
build.sc
example.html
example/src/example/Example.scala
example/src/example/Example5.scala
example/src/main/scala/example/Example.scala
example/src/main/scala/example/Example5.scala
example5.html
js/shared
jvm/shared
project/build.properties
project/plugins.sbt
version.sbt
--- a/.hgignore	Tue Jan 15 15:59:25 2019 +0100
+++ b/.hgignore	Thu Jan 17 14:51:59 2019 +0100
@@ -6,3 +6,5 @@
 lib_managed
 tags
 .idea
+out
+.idea_modules
--- a/build.sbt	Tue Jan 15 15:59:25 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-import scala.sys.process._
-
-val scalaVersions = Seq("2.11.12", "2.12.8")
-
-lazy val fatagsRoot = project.in(file(".")).
-  aggregate(fatagsJS, fatagsJVM, example).
-  settings(
-    crossScalaVersions := scalaVersions,
-    publish := {},
-    publishLocal := {}
-  )
-
-lazy val buildSettings = Seq(
-  organization := "net.tz",
-  name := "faTags",
-  scalaVersion := "2.12.4",
-  crossScalaVersions := scalaVersions,
-  scalacOptions ++= Seq(
-    "-feature", "-deprecation", "-unchecked",
-    "-language:implicitConversions", "-language:reflectiveCalls",
-    "-language:postfixOps"
-  ),
-  javacOptions ++= Seq(
-    "-encoding", "UTF-8", "-Xlint:deprecation", "-Xlint:unchecked"),
-  licenses += ("Apache-2.0", url("http://opensource.org/licenses/Apache-2.0"))
-)
-
-lazy val fatags = crossProject.in(file(".")).
-enablePlugins(BuildInfoPlugin).
-settings(buildSettings:_*).
-settings(
-  libraryDependencies ++= Seq(
-    "com.lihaoyi" %%% "scalatags" % "0.6.7"
-  ),
-
-  buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion,
-    "scalaJSVersion" -> scalaJSVersion,
-    BuildInfoKey.action("hgId") { "hg id -i".!!.trim },
-    BuildInfoKey.action("hgTags") { "hg id -t".!!.trim }
-  ),
-  buildInfoPackage := "fatags",
-  buildInfoOptions ++= Seq(BuildInfoOption.ToMap, BuildInfoOption.ToJson)
-
-).jvmSettings().jsSettings()
-
-lazy val fatagsJS = fatags.js
-lazy val fatagsJVM = fatags.jvm
-
-lazy val example = project.in(file("example"))
-  .enablePlugins(ScalaJSPlugin)
-  .dependsOn(fatagsJS)
-
-// vim: et ts=2 sw=2 syn=scala 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build.sc	Thu Jan 17 14:51:59 2019 +0100
@@ -0,0 +1,93 @@
+import ammonite.ops._
+import mill._
+import mill.define.{Input, Sources, Target}
+import mill.scalajslib._
+import mill.scalalib._
+import mill.scalalib.publish._
+import mill.util.Loose
+
+object V {
+  val fatags = "0.4-SNAPSHOT"
+  val scalaJs = "0.6.26"
+  val scala211 = "2.11.12"
+  val scala212 = "2.12.8"
+}
+
+object D {
+  val scalatags = ivy"com.lihaoyi::scalatags::0.6.7"
+}
+
+trait Common extends CrossSbtModule with PublishModule {
+
+  def publishVersion: Target[String] = V.fatags
+
+  def pomSettings = PomSettings(
+    description = "FontAwesome Scala DSL (tags)",
+    organization = "net.tz",
+    url = "https://bitbucket.org/tzeman/fatags",
+    licenses = Seq(License.`Apache-2.0`),
+    versionControl = VersionControl(developerConnection = Some(
+      "ssh://hg@bitbucket.org/tzeman/fatags")),
+    developers = Seq(
+      Developer("tzeman", "Tomas Zeman", "")
+    )
+  )
+
+  override def scalacOptions = T{Seq(
+    "-deprecation",                      // Emit warning and location for usages of deprecated APIs.
+    "-encoding", "utf-8",                // Specify character encoding used by source files.
+    "-explaintypes",                     // Explain type errors in more detail.
+    "-feature",                          // Emit warning and location for usages of features that should be imported explicitly.
+    "-language:higherKinds",             // Allow higher-kinded types
+    "-language:implicitConversions",     // Allow definition of implicit functions called views
+    "-language:reflectiveCalls",
+    "-language:postfixOps",
+    "-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",
+  )}
+
+  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
+  }
+
+  override def ivyDeps: Target[Loose.Agg[Dep]] = Agg(D.scalatags)
+
+  override def sources: Sources = T.sources{
+    super.sources() :+ PathRef(millSourcePath / 'shared / 'src / 'main / 'scala)
+  }
+
+}
+
+class JvmModule(val crossScalaVersion: String) extends Common
+class JsModule(val crossScalaVersion: String) extends ScalaJSModule
+  with Common {
+  override def scalaJSVersion: Target[String] = V.scalaJs
+}
+
+object jvm extends Cross[JvmModule](V.scala211, V.scala212)
+object js extends Cross[JsModule](V.scala211, V.scala212)
+
+def publishLocal(): define.Command[Unit] = T.command{
+  jvm(V.scala212).publishLocal()()
+  js(V.scala212).publishLocal()()
+  jvm(V.scala211).publishLocal()()
+  js(V.scala211).publishLocal()()
+}
+
+object example extends ScalaModule with ScalaJSModule {
+  override def moduleDeps: Seq[PublishModule] = Seq(js(V.scala212))
+  override def scalaVersion: Target[String] = T{V.scala212}
+  override def scalaJSVersion: Target[String] = V.scalaJs
+}
+
+// vim: et ts=2 sw=2 syn=scala
--- a/example.html	Tue Jan 15 15:59:25 2019 +0100
+++ b/example.html	Thu Jan 17 14:51:59 2019 +0100
@@ -9,8 +9,8 @@
 </head>
 
 <body>
-<div id="main">Please run sbt fastOptJS to build the demo. Then reload this page.</div>
-<script type="text/javascript" src="example/target/scala-2.12/example-fastopt.js"></script>
+<div id="main">Please run mill example.fastOptJS to build the demo. Then reload this page.</div>
+<script type="text/javascript" src="out/example/fastOpt/dest/out.js"></script>
 <script>
 Example.main();
 </script>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/src/example/Example.scala	Thu Jan 17 14:51:59 2019 +0100
@@ -0,0 +1,56 @@
+package example
+
+import fontawesome.jsdom.FA._
+import org.scalajs.dom
+import scalatags.JsDom.all._
+
+import scala.scalajs.js.annotation.{JSExport, JSExportTopLevel}
+
+@JSExportTopLevel("Example")
+object Example {
+
+  @JSExport
+  def main(): Unit = {
+    val el = dom.document.getElementById("main")
+    el.innerHTML = ""
+    el.appendChild(div(cls:="pure-u-1", margin:="1em",
+      h1("Font awesome demo..."),
+      h2("Larger icons"),
+      div(cls:="pure-g",
+        div(cls:="pure-u-1-5", faCameraRetro.lg, "fa-lg"),
+        div(cls:="pure-u-1-5", faCameraRetro.x2, "fa-2x"),
+        div(cls:="pure-u-1-5", faCameraRetro.x3, "fa-3x"),
+        div(cls:="pure-u-1-5", faCameraRetro.x4, "fa-4x"),
+        div(cls:="pure-u-1-5", faCameraRetro.x5, "fa-5x")
+      ),
+      h2("Fixed width icons (default)"),
+      div(cls:="pure-u-1", faHome, "Home"),
+      div(cls:="pure-u-1", faBook, "Library"),
+      div(cls:="pure-u-1", faPencil, "Applications"),
+      div(cls:="pure-u-1", faCog, "Settings"),
+      h2("No fixed width icons"),
+      div(cls:="pure-u-1",
+        faWifi.noFw, faWikipediaW.noFw, faWon.noFw, faWordpress.noFw,
+        faXing.noFw, faYahoo.noFw, faYelp.noFw, faYen.noFw,
+        faYoast.noFw, faYoutube.noFw),
+      h2("List icons"),
+      ul(cls:="fa-ul",
+        li(faCheckSquare.li, "List icons"),
+        li(faCheckSquare.li, "can be used"),
+        li(faSpinner.li.spin, "as bullets"),
+        li(faSquare.li, "in lists")
+      ),
+      h2("Bordered & Pulled Icons"),
+      div(cls:="pure-u-1-4",
+        faQuoteLeft.x3.pullLeft.border,
+        s"""...tomorrow we will run faster, stretch out our arms farther...
+             And then one fine morning - So we beat on, boats against the
+              current, borne back ceaselessly into the past."""),
+      h2("Animated Icons "),
+      div(cls:="pure-u-1",
+        faSpinner.x3.spin, faCircleONotch.x3.spin, faRefresh.x3.spin,
+        faCog.x3.spin, faSpinner.x3.pulse
+      )
+    ).render)
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/src/example/Example5.scala	Thu Jan 17 14:51:59 2019 +0100
@@ -0,0 +1,56 @@
+package example
+
+import fontawesome.jsdom.FA._
+import org.scalajs.dom
+import scalatags.JsDom.all._
+
+import scala.scalajs.js.annotation.{JSExport, JSExportTopLevel}
+
+@JSExportTopLevel("Example5")
+object Example5 {
+
+  @JSExport
+  def main(): Unit = {
+    val el = dom.document.getElementById("main")
+    el.innerHTML = ""
+    el.appendChild(div(cls:="pure-u-1", margin:="1em",
+      h1("Font awesome demo..."),
+      h2("Larger icons"),
+      div(cls:="pure-g",
+        div(cls:="pure-u-1-5", faCameraRetro.lg, "fa-lg"),
+        div(cls:="pure-u-1-5", faCameraRetro.x2, "fa-2x"),
+        div(cls:="pure-u-1-5", faCameraRetro.x3, "fa-3x"),
+        div(cls:="pure-u-1-5", faCameraRetro.x4, "fa-4x"),
+        div(cls:="pure-u-1-5", faCameraRetro.x5, "fa-5x")
+      ),
+      h2("Fixed width icons (default)"),
+      div(cls:="pure-u-1", faHome, "Home"),
+      div(cls:="pure-u-1", faBook, "Library"),
+      div(cls:="pure-u-1", faPencil, "Applications"),
+      div(cls:="pure-u-1", faCog, "Settings"),
+      h2("No fixed width icons"),
+      div(cls:="pure-u-1",
+        faWifi.noFw, faWikipediaW.noFw, faWon.noFw, faWordpress.noFw,
+        faXing.noFw, faYahoo.noFw, faYelp.noFw, faYen.noFw,
+        faYoast.noFw, faYoutube.noFw),
+      h2("List icons"),
+      ul(cls:="fa-ul",
+        li(faCheckSquare.li, "List icons"),
+        li(faCheckSquare.li, "can be used"),
+        li(faSpinner.li.spin, "as bullets"),
+        li(faSquare.li, "in lists")
+      ),
+      h2("Bordered & Pulled Icons"),
+      div(cls:="pure-u-1-4",
+        faQuoteLeft.x3.pullLeft.border,
+        s"""...tomorrow we will run faster, stretch out our arms farther...
+             And then one fine morning - So we beat on, boats against the
+              current, borne back ceaselessly into the past."""),
+      h2("Animated Icons "),
+      div(cls:="pure-u-1",
+        faSpinner.x3.spin, faCircleONotch.x3.spin, faRefresh.x3.spin,
+        faCog.x3.spin, faSpinner.x3.pulse
+      )
+    ).render)
+  }
+}
--- a/example/src/main/scala/example/Example.scala	Tue Jan 15 15:59:25 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-package example
-
-import fontawesome.jsdom.FA._
-import org.scalajs.dom
-import scalatags.JsDom.all._
-
-import scala.scalajs.js.annotation.{JSExport, JSExportTopLevel}
-
-@JSExportTopLevel("Example")
-object Example {
-
-  @JSExport
-  def main(): Unit = {
-    val el = dom.document.getElementById("main")
-    el.innerHTML = ""
-    el.appendChild(div(cls:="pure-u-1", margin:="1em",
-      h1("Font awesome demo..."),
-      h2("Larger icons"),
-      div(cls:="pure-g",
-        div(cls:="pure-u-1-5", faCameraRetro.lg, "fa-lg"),
-        div(cls:="pure-u-1-5", faCameraRetro.x2, "fa-2x"),
-        div(cls:="pure-u-1-5", faCameraRetro.x3, "fa-3x"),
-        div(cls:="pure-u-1-5", faCameraRetro.x4, "fa-4x"),
-        div(cls:="pure-u-1-5", faCameraRetro.x5, "fa-5x")
-      ),
-      h2("Fixed width icons (default)"),
-      div(cls:="pure-u-1", faHome, "Home"),
-      div(cls:="pure-u-1", faBook, "Library"),
-      div(cls:="pure-u-1", faPencil, "Applications"),
-      div(cls:="pure-u-1", faCog, "Settings"),
-      h2("No fixed width icons"),
-      div(cls:="pure-u-1",
-        faWifi.noFw, faWikipediaW.noFw, faWon.noFw, faWordpress.noFw,
-        faXing.noFw, faYahoo.noFw, faYelp.noFw, faYen.noFw,
-        faYoast.noFw, faYoutube.noFw),
-      h2("List icons"),
-      ul(cls:="fa-ul",
-        li(faCheckSquare.li, "List icons"),
-        li(faCheckSquare.li, "can be used"),
-        li(faSpinner.li.spin, "as bullets"),
-        li(faSquare.li, "in lists")
-      ),
-      h2("Bordered & Pulled Icons"),
-      div(cls:="pure-u-1-4",
-        faQuoteLeft.x3.pullLeft.border,
-        s"""...tomorrow we will run faster, stretch out our arms farther...
-             And then one fine morning - So we beat on, boats against the
-              current, borne back ceaselessly into the past."""),
-      h2("Animated Icons "),
-      div(cls:="pure-u-1",
-        faSpinner.x3.spin, faCircleONotch.x3.spin, faRefresh.x3.spin,
-        faCog.x3.spin, faSpinner.x3.pulse
-      )
-    ).render)
-  }
-}
--- a/example/src/main/scala/example/Example5.scala	Tue Jan 15 15:59:25 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-package example
-
-import fontawesome.jsdom.FA._
-import org.scalajs.dom
-import scalatags.JsDom.all._
-
-import scala.scalajs.js.annotation.{JSExport, JSExportTopLevel}
-
-@JSExportTopLevel("Example5")
-object Example5 {
-
-  @JSExport
-  def main(): Unit = {
-    val el = dom.document.getElementById("main")
-    el.innerHTML = ""
-    el.appendChild(div(cls:="pure-u-1", margin:="1em",
-      h1("Font awesome demo..."),
-      h2("Larger icons"),
-      div(cls:="pure-g",
-        div(cls:="pure-u-1-5", faCameraRetro.lg, "fa-lg"),
-        div(cls:="pure-u-1-5", faCameraRetro.x2, "fa-2x"),
-        div(cls:="pure-u-1-5", faCameraRetro.x3, "fa-3x"),
-        div(cls:="pure-u-1-5", faCameraRetro.x4, "fa-4x"),
-        div(cls:="pure-u-1-5", faCameraRetro.x5, "fa-5x")
-      ),
-      h2("Fixed width icons (default)"),
-      div(cls:="pure-u-1", faHome, "Home"),
-      div(cls:="pure-u-1", faBook, "Library"),
-      div(cls:="pure-u-1", faPencil, "Applications"),
-      div(cls:="pure-u-1", faCog, "Settings"),
-      h2("No fixed width icons"),
-      div(cls:="pure-u-1",
-        faWifi.noFw, faWikipediaW.noFw, faWon.noFw, faWordpress.noFw,
-        faXing.noFw, faYahoo.noFw, faYelp.noFw, faYen.noFw,
-        faYoast.noFw, faYoutube.noFw),
-      h2("List icons"),
-      ul(cls:="fa-ul",
-        li(faCheckSquare.li, "List icons"),
-        li(faCheckSquare.li, "can be used"),
-        li(faSpinner.li.spin, "as bullets"),
-        li(faSquare.li, "in lists")
-      ),
-      h2("Bordered & Pulled Icons"),
-      div(cls:="pure-u-1-4",
-        faQuoteLeft.x3.pullLeft.border,
-        s"""...tomorrow we will run faster, stretch out our arms farther...
-             And then one fine morning - So we beat on, boats against the
-              current, borne back ceaselessly into the past."""),
-      h2("Animated Icons "),
-      div(cls:="pure-u-1",
-        faSpinner.x3.spin, faCircleONotch.x3.spin, faRefresh.x3.spin,
-        faCog.x3.spin, faSpinner.x3.pulse
-      )
-    ).render)
-  }
-}
--- a/example5.html	Tue Jan 15 15:59:25 2019 +0100
+++ b/example5.html	Thu Jan 17 14:51:59 2019 +0100
@@ -11,7 +11,7 @@
 
 <body>
 <div id="main">Please run sbt fastOptJS to build the demo. Then reload this page.</div>
-<script type="text/javascript" src="example/target/scala-2.12/example-fastopt.js"></script>
+<script type="text/javascript" src="out/example/fastOpt/dest/out.js"></script>
 <script>
 Example5.main();
 </script>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/js/shared	Thu Jan 17 14:51:59 2019 +0100
@@ -0,0 +1,1 @@
+../shared
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jvm/shared	Thu Jan 17 14:51:59 2019 +0100
@@ -0,0 +1,1 @@
+../shared
\ No newline at end of file
--- a/project/build.properties	Tue Jan 15 15:59:25 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-sbt.version=1.0.4
--- a/project/plugins.sbt	Tue Jan 15 15:59:25 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-// Resolvers
-resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
-
-resolvers += Resolver.url("scala-js-snapshots", 
-  url("http://repo.scala-js.org/repo/snapshots/"))(Resolver.ivyStylePatterns)
-
-// Sbt plugins
-addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.26")
-
-addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0")
-
-addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.1")
--- a/version.sbt	Tue Jan 15 15:59:25 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-version in ThisBuild := "0.4-SNAPSHOT"