summaryrefslogtreecommitdiff
path: root/contrib/twirllib
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-11-05 03:00:04 +0800
committerLi Haoyi <haoyi.sg@gmail.com>2018-11-05 21:14:58 +0800
commitbc9dc386625021fec517f2dbf0644ccafe1e32c2 (patch)
tree12db6817470708c7aa274aa231ef35eb79f2123a /contrib/twirllib
parent8afe79afe33be68f59f89b8410984e508c3e8d08 (diff)
downloadmill-bc9dc386625021fec517f2dbf0644ccafe1e32c2.tar.gz
mill-bc9dc386625021fec517f2dbf0644ccafe1e32c2.tar.bz2
mill-bc9dc386625021fec517f2dbf0644ccafe1e32c2.zip
WIP migrating over from `ammonite.ops` to `os` module.
__.compile works, haven't run tests yet
Diffstat (limited to 'contrib/twirllib')
-rw-r--r--contrib/twirllib/src/mill/twirllib/TwirlWorker.scala17
-rw-r--r--contrib/twirllib/test/src/mill/twirllib/HelloWorldTests.scala19
2 files changed, 17 insertions, 19 deletions
diff --git a/contrib/twirllib/src/mill/twirllib/TwirlWorker.scala b/contrib/twirllib/src/mill/twirllib/TwirlWorker.scala
index b73ed5dc..ce8175a6 100644
--- a/contrib/twirllib/src/mill/twirllib/TwirlWorker.scala
+++ b/contrib/twirllib/src/mill/twirllib/TwirlWorker.scala
@@ -5,7 +5,6 @@ import java.io.File
import java.lang.reflect.Method
import java.net.URLClassLoader
-import ammonite.ops.{Path, ls}
import mill.eval.PathRef
import mill.scalalib.CompilationResult
@@ -15,8 +14,8 @@ class TwirlWorker {
private var twirlInstanceCache = Option.empty[(Long, TwirlWorkerApi)]
- private def twirl(twirlClasspath: Agg[Path]) = {
- val classloaderSig = twirlClasspath.map(p => p.toString().hashCode + p.mtime.toMillis).sum
+ private def twirl(twirlClasspath: Agg[os.Path]) = {
+ val classloaderSig = twirlClasspath.map(p => p.toString().hashCode + os.mtime(p)).sum
twirlInstanceCache match {
case Some((sig, instance)) if sig == classloaderSig => instance
case _ =>
@@ -61,9 +60,9 @@ class TwirlWorker {
}
}
- def compile(twirlClasspath: Agg[Path],
- sourceDirectories: Seq[Path],
- dest: Path,
+ def compile(twirlClasspath: Agg[os.Path],
+ sourceDirectories: Seq[os.Path],
+ dest: os.Path,
additionalImports: Seq[String],
constructorAnnotations: Seq[String],
codec: Codec,
@@ -71,10 +70,10 @@ class TwirlWorker {
(implicit ctx: mill.util.Ctx): mill.eval.Result[CompilationResult] = {
val compiler = twirl(twirlClasspath)
- def compileTwirlDir(inputDir: Path) {
- ls.rec(inputDir).filter(_.name.matches(".*.scala.(html|xml|js|txt)"))
+ def compileTwirlDir(inputDir: os.Path) {
+ os.walk(inputDir).filter(_.last.matches(".*.scala.(html|xml|js|txt)"))
.foreach { template =>
- val extFormat = twirlExtensionFormat(template.name)
+ val extFormat = twirlExtensionFormat(template.last)
compiler.compileTwirl(template.toIO,
inputDir.toIO,
dest.toIO,
diff --git a/contrib/twirllib/test/src/mill/twirllib/HelloWorldTests.scala b/contrib/twirllib/test/src/mill/twirllib/HelloWorldTests.scala
index 8ef6ee3e..f14a607b 100644
--- a/contrib/twirllib/test/src/mill/twirllib/HelloWorldTests.scala
+++ b/contrib/twirllib/test/src/mill/twirllib/HelloWorldTests.scala
@@ -1,6 +1,5 @@
package mill.twirllib
-import ammonite.ops.{Path, cp, ls, mkdir, pwd, rm, _}
import mill.util.{TestEvaluator, TestUtil}
import utest.framework.TestPath
import utest.{TestSuite, Tests, assert, _}
@@ -8,7 +7,7 @@ import utest.{TestSuite, Tests, assert, _}
object HelloWorldTests extends TestSuite {
trait HelloBase extends TestUtil.BaseModule {
- override def millSourcePath: Path = TestUtil.getSrcPathBase() / millOuterCtx.enclosing.split('.')
+ override def millSourcePath: os.Path = TestUtil.getSrcPathBase() / millOuterCtx.enclosing.split('.')
}
trait HelloWorldModule extends mill.twirllib.TwirlModule {
@@ -22,20 +21,20 @@ object HelloWorldTests extends TestSuite {
}
}
- val resourcePath: Path = pwd / 'contrib / 'twirllib / 'test / 'resources / "hello-world"
+ val resourcePath: os.Path = os.pwd / 'contrib / 'twirllib / 'test / 'resources / "hello-world"
- def workspaceTest[T](m: TestUtil.BaseModule, resourcePath: Path = resourcePath)
+ def workspaceTest[T](m: TestUtil.BaseModule, resourcePath: os.Path = resourcePath)
(t: TestEvaluator => T)
(implicit tp: TestPath): T = {
val eval = new TestEvaluator(m)
- rm(m.millSourcePath)
- rm(eval.outPath)
- mkdir(m.millSourcePath / up)
- cp(resourcePath, m.millSourcePath)
+ os.remove.all(m.millSourcePath)
+ os.remove.all(eval.outPath)
+ os.makeDir.all(m.millSourcePath / os.up)
+ os.copy(resourcePath, m.millSourcePath)
t(eval)
}
- def compileClassfiles: Seq[RelPath] = Seq[RelPath](
+ def compileClassfiles: Seq[os.RelPath] = Seq[os.RelPath](
"hello.template.scala"
)
@@ -54,7 +53,7 @@ object HelloWorldTests extends TestSuite {
'compileTwirl - workspaceTest(HelloWorld) { eval =>
val Right((result, evalCount)) = eval.apply(HelloWorld.core.compileTwirl)
- val outputFiles = ls.rec(result.classes.path)
+ val outputFiles = os.walk(result.classes.path)
val expectedClassfiles = compileClassfiles.map(
eval.outPath / 'core / 'compileTwirl / 'dest / 'html / _
)