diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-11-05 03:00:04 +0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-11-05 21:14:58 +0800 |
commit | bc9dc386625021fec517f2dbf0644ccafe1e32c2 (patch) | |
tree | 12db6817470708c7aa274aa231ef35eb79f2123a /contrib/scalapblib | |
parent | 8afe79afe33be68f59f89b8410984e508c3e8d08 (diff) | |
download | mill-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/scalapblib')
-rw-r--r-- | contrib/scalapblib/src/mill/contrib/scalapblib/ScalaPBWorker.scala | 11 | ||||
-rw-r--r-- | contrib/scalapblib/test/src/mill/contrib/scalapblib/TutorialTests.scala | 21 |
2 files changed, 15 insertions, 17 deletions
diff --git a/contrib/scalapblib/src/mill/contrib/scalapblib/ScalaPBWorker.scala b/contrib/scalapblib/src/mill/contrib/scalapblib/ScalaPBWorker.scala index ea11a624..a1b345b4 100644 --- a/contrib/scalapblib/src/mill/contrib/scalapblib/ScalaPBWorker.scala +++ b/contrib/scalapblib/src/mill/contrib/scalapblib/ScalaPBWorker.scala @@ -5,15 +5,14 @@ import java.io.File import java.lang.reflect.Method import java.net.URLClassLoader -import ammonite.ops.{Path, ls} import mill.eval.PathRef class ScalaPBWorker { private var scalaPBInstanceCache = Option.empty[(Long, ScalaPBWorkerApi)] - private def scalaPB(scalaPBClasspath: Agg[Path]) = { - val classloaderSig = scalaPBClasspath.map(p => p.toString().hashCode + p.mtime.toMillis).sum + private def scalaPB(scalaPBClasspath: Agg[os.Path]) = { + val classloaderSig = scalaPBClasspath.map(p => p.toString().hashCode + os.mtime(p)).sum scalaPBInstanceCache match { case Some((sig, instance)) if sig == classloaderSig => instance case _ => @@ -40,14 +39,14 @@ class ScalaPBWorker { } } - def compile(scalaPBClasspath: Agg[Path], scalaPBSources: Seq[Path], scalaPBOptions: String, dest: Path) + def compile(scalaPBClasspath: Agg[os.Path], scalaPBSources: Seq[os.Path], scalaPBOptions: String, dest: os.Path) (implicit ctx: mill.util.Ctx): mill.eval.Result[PathRef] = { val compiler = scalaPB(scalaPBClasspath) - def compileScalaPBDir(inputDir: Path) { + def compileScalaPBDir(inputDir: os.Path) { // ls throws if the path doesn't exist if (inputDir.toIO.exists) { - ls.rec(inputDir).filter(_.name.matches(".*.proto")) + os.walk(inputDir).filter(_.last.matches(".*.proto")) .foreach { proto => compiler.compileScalaPB(proto.toIO, scalaPBOptions, dest.toIO) } diff --git a/contrib/scalapblib/test/src/mill/contrib/scalapblib/TutorialTests.scala b/contrib/scalapblib/test/src/mill/contrib/scalapblib/TutorialTests.scala index 8542d60e..65558f72 100644 --- a/contrib/scalapblib/test/src/mill/contrib/scalapblib/TutorialTests.scala +++ b/contrib/scalapblib/test/src/mill/contrib/scalapblib/TutorialTests.scala @@ -1,6 +1,5 @@ package mill.contrib.scalapblib -import ammonite.ops.{Path, cp, ls, mkdir, pwd, rm, _} import mill.eval.Result import mill.util.{TestEvaluator, TestUtil} import utest.framework.TestPath @@ -9,7 +8,7 @@ import utest.{TestSuite, Tests, assert, _} object TutorialTests extends TestSuite { trait TutorialBase extends TestUtil.BaseModule { - override def millSourcePath: Path = TestUtil.getSrcPathBase() / millOuterCtx.enclosing.split('.') + override def millSourcePath: os.Path = TestUtil.getSrcPathBase() / millOuterCtx.enclosing.split('.') } trait TutorialModule extends ScalaPBModule { @@ -25,24 +24,24 @@ object TutorialTests extends TestSuite { } } - val resourcePath: Path = pwd / 'contrib / 'scalapblib / 'test / 'protobuf / 'tutorial + val resourcePath: os.Path = os.pwd / 'contrib / 'scalapblib / 'test / 'protobuf / 'tutorial - def protobufOutPath(eval: TestEvaluator): Path = + def protobufOutPath(eval: TestEvaluator): os.Path = eval.outPath / 'core / 'compileScalaPB / 'dest / 'com / 'example / 'tutorial def workspaceTest[T](m: TestUtil.BaseModule)(t: TestEvaluator => T) (implicit tp: TestPath): T = { val eval = new TestEvaluator(m) - rm(m.millSourcePath) + os.remove.all(m.millSourcePath) println(m.millSourcePath) - rm(eval.outPath) + os.remove.all(eval.outPath) println(eval.outPath) - mkdir(m.millSourcePath / 'core / 'protobuf) - cp(resourcePath, m.millSourcePath / 'core / 'protobuf / 'tutorial) + os.makeDir.all(m.millSourcePath / 'core / 'protobuf) + os.copy(resourcePath, m.millSourcePath / 'core / 'protobuf / 'tutorial) t(eval) } - def compiledSourcefiles: Seq[RelPath] = Seq[RelPath]( + def compiledSourcefiles: Seq[os.RelPath] = Seq[os.RelPath]( "AddressBook.scala", "Person.scala", "TutorialProto.scala" @@ -67,7 +66,7 @@ object TutorialTests extends TestSuite { val outPath = protobufOutPath(eval) - val outputFiles = ls.rec(result.path).filter(_.isFile) + val outputFiles = os.walk(result.path).filter(os.isFile) val expectedSourcefiles = compiledSourcefiles.map(outPath / _) @@ -92,7 +91,7 @@ object TutorialTests extends TestSuite { // val outPath = protobufOutPath(eval) - // val outputFiles = ls.rec(outPath).filter(_.isFile) + // val outputFiles = os.walk(outPath).filter(_.isFile) // val expectedSourcefiles = compiledSourcefiles.map(outPath / _) |