build.sc
changeset 1 3a70d40db0fd
child 3 a6bf3dddbb7c
equal deleted inserted replaced
0:5f36886fdb1b 1:3a70d40db0fd
       
     1 // mill 0.3.6
       
     2 
       
     3 import ammonite.ops._
       
     4 import mill._
       
     5 import mill.define.{Input, Sources, Target}
       
     6 import mill.scalajslib._
       
     7 import mill.scalalib._
       
     8 import mill.scalalib.publish._
       
     9 
       
    10 import scala.language.postfixOps
       
    11 
       
    12 object V {
       
    13   val spss4s = "0.1-SNAPSHOT"
       
    14   val scalaJs = "0.6.26"
       
    15   val scala211 = "2.11.12"
       
    16   val scala212 = "2.12.8"
       
    17 }
       
    18 
       
    19 object D {
       
    20   val spssReader = ivy"com.bedatadriven.spss:spss-reader:1.2"
       
    21 }
       
    22 
       
    23 trait Common extends CrossScalaModule with PublishModule {
       
    24 
       
    25   def publishVersion: Input[String] = T.input{
       
    26     val tv = hgTag() map(v => "-" + v.replace(".patch", "")) getOrElse ""
       
    27     V.spss4s.replace("SNAPSHOT", s"${hgNum()}-${hgId()}$tv")
       
    28   }
       
    29 
       
    30   def pomSettings = PomSettings(
       
    31     description = "SPSS reader for Scala",
       
    32     organization = "net.tz",
       
    33     url = "https://bitbucket.org/tzeman/spss4s",
       
    34     licenses = Seq(License.`Apache-2.0`),
       
    35     versionControl = VersionControl(developerConnection = Some(
       
    36       "ssh://hg@bitbucket.org/tzeman/spss4s")),
       
    37     developers = Seq(
       
    38       Developer("tzeman", "Tomas Zeman", "")
       
    39     )
       
    40   )
       
    41 
       
    42   override def scalacOptions = T{Seq(
       
    43     "-deprecation",                      // Emit warning and location for usages of deprecated APIs.
       
    44     "-encoding", "utf-8",                // Specify character encoding used by source files.
       
    45     "-explaintypes",                     // Explain type errors in more detail.
       
    46     "-feature",                          // Emit warning and location for usages of features that should be imported explicitly.
       
    47     "-language:higherKinds",             // Allow higher-kinded types
       
    48     "-language:implicitConversions",     // Allow definition of implicit functions called views
       
    49     "-language:reflectiveCalls",
       
    50     "-language:postfixOps",
       
    51     "-unchecked",                        // Enable additional warnings where generated code depends on assumptions.
       
    52     "-Xcheckinit",                       // Wrap field accessors to throw an exception on uninitialized access.
       
    53     "-Xfuture",                          // Turn on future language features.
       
    54     "-target:jvm-1.8",
       
    55   )}
       
    56 
       
    57   def hgId: Input[String] = T.input {
       
    58     os.proc("hg", "id", "-i").call().out.string.trim
       
    59   }
       
    60 
       
    61   def hgNum: Input[String] = T.input {
       
    62     os.proc("hg", "id", "-n").call().out.string.trim
       
    63   }
       
    64 
       
    65   def hgTag: Input[Option[String]] = T.input {
       
    66     os.proc("hg", "id", "-t").call().out.string.trim.split(' ').headOption
       
    67   }
       
    68 
       
    69   override def sources: Sources = T.sources(
       
    70     millSourcePath / 'src, millSourcePath / 'shared
       
    71   )
       
    72 
       
    73 }
       
    74 
       
    75 class JvmModule(val crossScalaVersion: String) extends Common {
       
    76 
       
    77   override def ivyDeps = Agg(D.spssReader)
       
    78 
       
    79 }
       
    80 
       
    81 class JsModule(val crossScalaVersion: String) extends ScalaJSModule
       
    82   with Common {
       
    83   override def scalaJSVersion: Target[String] = V.scalaJs
       
    84 }
       
    85 
       
    86 object jvm extends Cross[JvmModule](V.scala211, V.scala212)
       
    87 object js extends Cross[JsModule](V.scala211, V.scala212)
       
    88 
       
    89 def publishLocal(): define.Command[Unit] = T.command{
       
    90   jvm(V.scala212).publishLocal()()
       
    91   js(V.scala212).publishLocal()()
       
    92   jvm(V.scala211).publishLocal()()
       
    93   js(V.scala211).publishLocal()()
       
    94 }
       
    95 
       
    96 // vim: et ts=2 sw=2 syn=scala