# HG changeset patch # User Tomas Zeman # Date 1590592029 -7200 # Node ID 13abcbe6368be10d77c81cfbff389d66f38ff558 # Parent bdde11c9c9fdc706a918838058b2b4824000cf21 purecss: refactored build sbt -> mill diff -r bdde11c9c9fd -r 13abcbe6368b .hgignore --- a/.hgignore Thu Oct 24 10:15:43 2019 +0200 +++ b/.hgignore Wed May 27 17:07:09 2020 +0200 @@ -6,3 +6,4 @@ lib_managed tags .idea +out diff -r bdde11c9c9fd -r 13abcbe6368b build.sbt --- a/build.sbt Thu Oct 24 10:15:43 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -import scala.sys.process._ - -val scalaVersions = Seq("2.11.12", "2.12.4") - -lazy val purecss = project.in(file(".")). - aggregate(purecssJS, purecssJVM). - settings( - crossScalaVersions := scalaVersions, - publish := {}, - publishLocal := {}, - bintrayVcsUrl := Some("https://bitbucket.org/tzeman/purecss") - ) - -lazy val buildSettings = Seq( - organization := "net.tz", - name := "purecss", - 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")), - bintrayVcsUrl := Some("https://bitbucket.org/tzeman/purecss") -) - -lazy val purecssProject = 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 := "purecss.build", - buildInfoOptions ++= Seq(BuildInfoOption.ToMap, BuildInfoOption.ToJson) - -).jvmSettings( - initialCommands in console := """ - import scalatags.Text.all._ - import purecss.text.PureCss._ - """ -).jsSettings() - -lazy val purecssJS = purecssProject.js -lazy val purecssJVM = purecssProject.jvm - -// vim: et ts=2 sw=2 syn=scala diff -r bdde11c9c9fd -r 13abcbe6368b build.sc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/build.sc Wed May 27 17:07:09 2020 +0200 @@ -0,0 +1,99 @@ +import mill._ +import mill.api.Loose +import mill.define.{Command, Input, Sources, Target} +import mill.scalajslib._ +import mill.scalalib._ +import mill.scalalib.publish._ + +object V { + val app = "0.2-SNAPSHOT" + val scalaJs = "0.6.28" + val scala211 = "2.11.12" + val scala212 = "2.12.9" +} + +object D { + val scalatags = ivy"com.lihaoyi::scalatags::0.6.8" +} + +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", + url = "https://hg.functionals.cz/purecss", + licenses = Seq(License.`Apache-2.0`), + versionControl = VersionControl(developerConnection = Some( + "https://hg.functionals.cz/purecss")), + developers = Seq( + Developer("tzeman", "Tomas Zeman", "https://functionals.cz") + ) + ) + + override def artifactName = "purecss" + + 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 + } + + 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 => + maskedTags contains v).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(): Command[Unit] = T.command{ + jvm(V.scala212).publishLocal()() + js(V.scala212).publishLocal()() + jvm(V.scala211).publishLocal()() + js(V.scala211).publishLocal()() + () +} + +def publishM2Local(p: os.Path): Command[Unit] = T.command{ + jvm(V.scala212).publishM2Local(p.toString)() + js(V.scala212).publishM2Local(p.toString)() + jvm(V.scala211).publishM2Local(p.toString)() + js(V.scala211).publishM2Local(p.toString)() + () +} + +// vim: et ts=2 sw=2 syn=scala diff -r bdde11c9c9fd -r 13abcbe6368b js/shared --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/js/shared Wed May 27 17:07:09 2020 +0200 @@ -0,0 +1,1 @@ +../shared \ No newline at end of file diff -r bdde11c9c9fd -r 13abcbe6368b jvm/shared --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jvm/shared Wed May 27 17:07:09 2020 +0200 @@ -0,0 +1,1 @@ +../shared \ No newline at end of file diff -r bdde11c9c9fd -r 13abcbe6368b mill --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mill Wed May 27 17:07:09 2020 +0200 @@ -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.3 + +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 "$@" diff -r bdde11c9c9fd -r 13abcbe6368b version.sbt --- a/version.sbt Thu Oct 24 10:15:43 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -version in ThisBuild := "0.2-SNAPSHOT"