build.sc: recompile if .scalatex file changes
authorTomas Zeman <tzeman@volny.cz>
Tue, 18 Dec 2018 10:46:09 +0100
changeset 22 b5c85ad66f17
parent 21 1fa630ed9b8a
child 23 afcfbdeb3b88
build.sc: recompile if .scalatex file changes
build.sc
--- a/build.sc	Thu Dec 13 17:33:35 2018 +0100
+++ b/build.sc	Tue Dec 18 10:46:09 2018 +0100
@@ -1,6 +1,6 @@
 import ammonite.ops._
 import mill._
-import mill.define.{Input, Target}
+import mill.define.{Input, Sources, Target}
 import mill.scalajslib._
 import mill.scalalib._
 import mill.scalalib.publish._
@@ -108,12 +108,12 @@
 
   override def moduleDeps = Seq(base)
 
-  def contentSources: Target[PathRef]
+  def contentSources: Sources
 
   override def generatedSources: Target[Seq[PathRef]] = T{
     val dir = T.ctx().dest
-    val src = contentSources().path
-    val ids = ls! src filter(_.name endsWith ".scalatex") map { p =>
+    val src = contentSources() map(_.path)
+    val ids = src flatMap(ls! _ filter(_.name endsWith ".scalatex") map { p =>
       val id = p.name replaceAllLiterally (".scalatex", "")
       val aid = s"article-$id"
       write(dir / s"$id.scala",
@@ -128,9 +128,13 @@
           |   implicit val id = Articles.Id("$id")
           |   twf("${p.toString}")
           | }
+          |
+          |/*
+          |${os.read(p).lines mkString "\n"}
+          |*/
         """.stripMargin)
       aid
-    }
+    })
 
     write(dir / "initializer.scala",
       s"""
@@ -161,13 +165,13 @@
 }
 
 object example extends Content {
-  def contentSources: Target[PathRef] =
-    T{ PathRef(millSourcePath / up / 'example / 'content) }
+  def contentSources: Sources =
+    T.sources{ millSourcePath / up / 'example / 'content }
 }
 
 object production extends Content {
-  def contentSources: Target[PathRef] =
-    T{ PathRef(millSourcePath / up / 'production / 'content) }
+  def contentSources: Sources =
+    T.sources{ millSourcePath / up / 'production / 'content }
 }