Build split: example + production
authorTomas Zeman <tzeman@volny.cz>
Thu, 13 Dec 2018 17:29:58 +0100
changeset 20 677672b9e386
parent 19 83fb90bdd15b
child 21 1fa630ed9b8a
Build split: example + production
build.sc
--- a/build.sc	Thu Dec 13 15:15:13 2018 +0100
+++ b/build.sc	Thu Dec 13 17:29:58 2018 +0100
@@ -1,6 +1,6 @@
 import ammonite.ops._
 import mill._
-import mill.define.{Input, Sources, Target}
+import mill.define.{Input, Target}
 import mill.scalajslib._
 import mill.scalalib._
 import mill.scalalib.publish._
@@ -15,7 +15,7 @@
 trait Common extends ScalaModule with PublishModule {
   val scalaVersion = scalaVer
 
-  def publishVersion = appVersion 
+  def publishVersion: Target[String] = appVersion
 
   def pomSettings = PomSettings(
     description = "Content management system for SQWL",
@@ -62,9 +62,10 @@
 }
 
 object base extends Common with Versions {
-  override def scalacPluginIvyDeps: Target[Loose.Agg[Dep]] = super.scalacPluginIvyDeps() ++ Agg(
-    ivy"org.scalamacros:::paradise:2.1.0"
-  )
+  override def scalacPluginIvyDeps: Target[Loose.Agg[Dep]] =
+    super.scalacPluginIvyDeps() ++ Agg(
+      ivy"org.scalamacros:::paradise:2.1.0"
+    )
 
   override def ivyDeps = Agg(
     ivy"com.wacai::config-annotation:0.3.6",
@@ -103,12 +104,15 @@
 
 }
 
-object content extends Common {
+trait Content extends Common {
+
   override def moduleDeps = Seq(base)
-  override def sources : Sources = T.sources{ millSourcePath / up / 'example / 'src }
+
+  def contentSources: Target[PathRef]
+
   override def generatedSources: Target[Seq[PathRef]] = T{
     val dir = T.ctx().dest
-    val src = millSourcePath / up / 'example / 'content
+    val src = contentSources().path
     val ids = ls! src filter(_.name endsWith ".scalatex") map { p =>
       val id = p.name replaceAllLiterally (".scalatex", "")
       val aid = s"article-$id"
@@ -127,6 +131,7 @@
         """.stripMargin)
       aid
     }
+
     write(dir / "initializer.scala",
       s"""
         | package sqwl.cms
@@ -136,19 +141,7 @@
         |   }
         | }
       """.stripMargin)
-    Seq(PathRef(dir))
-  }
-  override def ivyDeps = Agg(
-    ivy"com.beachape::enumeratum:1.5.13"
-  )
-}
 
-object app extends Common {
-  override def moduleDeps = Seq(content)
-  override def mainClass = Some("sqwl.cms.Main")
-
-  override def generatedSources: Target[Seq[PathRef]] = T{
-    val dir = T.ctx().dest
     write(dir / "main.scala",
       """
         | package sqwl.cms
@@ -156,10 +149,28 @@
         |   override def content: iContent = Content
         | }
       """.stripMargin)
+
     Seq(PathRef(dir))
   }
+
+  override def mainClass = Some("sqwl.cms.Main")
+
+  override def ivyDeps = Agg(
+    ivy"com.beachape::enumeratum:1.5.13"
+  )
 }
 
+object example extends Content {
+  def contentSources: Target[PathRef] =
+    T{ PathRef(millSourcePath / up / 'example / 'content) }
+}
+
+object production extends Content {
+  def contentSources: Target[PathRef] =
+    T{ PathRef(millSourcePath / up / 'production / 'content) }
+}
+
+
 object js extends Common with ScalaJSModule {
   def scalaJSVersion: Target[String] = scalaJsVer
 }