From bc9dc386625021fec517f2dbf0644ccafe1e32c2 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 5 Nov 2018 03:00:04 +0800 Subject: WIP migrating over from `ammonite.ops` to `os` module. __.compile works, haven't run tests yet --- docs/build.sc | 20 ++++++++++---------- docs/logo.sc | 2 +- docs/pages/2 - Configuring Mill.md | 4 ++-- docs/pages/4 - Tasks.md | 26 +++++++++++++------------- docs/pages/9 - Contrib Modules.md | 2 +- 5 files changed, 27 insertions(+), 27 deletions(-) (limited to 'docs') diff --git a/docs/build.sc b/docs/build.sc index 42a4f141..661aa462 100644 --- a/docs/build.sc +++ b/docs/build.sc @@ -4,7 +4,7 @@ import $file.pageStyles, pageStyles._ import $file.pages, pages._ import scalatags.Text.all._ -import ammonite.ops._ + import collection.JavaConverters._ import org.pegdown.{PegDownProcessor, ToHtmlSerializer, LinkRenderer, Extensions} import org.pegdown.ast.{VerbatimNode, ExpImageNode, HeaderNode, TextNode, SimpleNode, TableNode} @@ -134,18 +134,18 @@ def formatRssDate(date: java.time.LocalDate) = { @main def main(publish: Boolean = false) = { - rm! targetFolder + os.remove.all! targetFolder - mkdir! targetFolder/'page + os.makeDir.all! targetFolder/'page for(otherFile <- otherFiles){ - cp(otherFile, targetFolder/'page/(otherFile relativeTo postsFolder)) + os.copy(otherFile, targetFolder/'page/(otherFile relativeTo postsFolder)) } - cp(pwd/"favicon.png", targetFolder/"favicon.ico") - cp(pwd/"logo-white.svg", targetFolder/"logo-white.svg") - cp(pwd/"VisualizeCompile.svg", targetFolder/"VisualizeCompile.svg") - cp(pwd/"VisualizeCore.svg", targetFolder/"VisualizeCore.svg") - cp(pwd/"VisualizePlan.svg", targetFolder/"VisualizePlan.svg") + os.copy(pwd/"favicon.png", targetFolder/"favicon.ico") + os.copy(pwd/"logo-white.svg", targetFolder/"logo-white.svg") + os.copy(pwd/"VisualizeCompile.svg", targetFolder/"VisualizeCompile.svg") + os.copy(pwd/"VisualizeCore.svg", targetFolder/"VisualizeCore.svg") + os.copy(pwd/"VisualizePlan.svg", targetFolder/"VisualizePlan.svg") %('zip, "-r", targetFolder/"example-1.zip", "example-1")(pwd) %('zip, "-r", targetFolder/"example-2.zip", "example-2")(pwd) @@ -171,7 +171,7 @@ def main(publish: Boolean = false) = { ) - write( + os.write( if (i == 0) targetFolder / "index.html" else targetFolder/'page/s"${sanitize(post.name)}.html", postContent( diff --git a/docs/logo.sc b/docs/logo.sc index 5d8cee3b..3464f9a9 100644 --- a/docs/logo.sc +++ b/docs/logo.sc @@ -2,7 +2,7 @@ import $ivy.`com.lihaoyi::scalatags:0.6.7` import scalatags.Text.implicits._ import scalatags.Text.svgTags._ import scalatags.Text.svgAttrs._ -import ammonite.ops._ + val svgWidth = 24 val svgHeight = 24 diff --git a/docs/pages/2 - Configuring Mill.md b/docs/pages/2 - Configuring Mill.md index 989272dd..f5a4a24e 100644 --- a/docs/pages/2 - Configuring Mill.md +++ b/docs/pages/2 - Configuring Mill.md @@ -291,8 +291,8 @@ object foo extends ScalaModule { } def lineCount = T { - import ammonite.ops._ - foo.sources().flatMap(ref => ls.rec(ref.path)).filter(_.isFile).flatMap(read.lines).size + + foo.sources().flatMap(ref => os.walk(ref.path)).filter(_.isFile).flatMap(read.lines).size } def printLineCount() = T.command { diff --git a/docs/pages/4 - Tasks.md b/docs/pages/4 - Tasks.md index e8a1c94c..e69ae662 100644 --- a/docs/pages/4 - Tasks.md +++ b/docs/pages/4 - Tasks.md @@ -5,22 +5,22 @@ for building Scala. The following is a simple self-contained example using Mill to compile Java: ```scala -import ammonite.ops._, mill._ +, mill._ // sourceRoot -> allSources -> classFiles // | // v // resourceRoot ----> jar -def sourceRoot = T.sources { pwd / 'src } +def sourceRoot = T.sources { os.pwd / 'src } -def resourceRoot = T.sources { pwd / 'resources } +def resourceRoot = T.sources { os.pwd / 'resources } -def allSources = T { sourceRoot().flatMap(p => ls.rec(p.path)).map(PathRef(_)) } +def allSources = T { sourceRoot().flatMap(p => os.walk(p.path)).map(PathRef(_)) } def classFiles = T { - mkdir(T.ctx().dest) - import ammonite.ops._ + os.makeDir.all(T.ctx().dest) + %("javac", sources().map(_.path.toString()), "-d", T.ctx().dest)(wd = T.ctx().dest) PathRef(T.ctx().dest) } @@ -28,7 +28,7 @@ def classFiles = T { def jar = T { Jvm.createJar(Loose.Agg(classFiles().path) ++ resourceRoot().map(_.path)) } def run(mainClsName: String) = T.command { - %%('java, "-cp", classFiles().path, mainClsName) + os.proc('java, "-cp", classFiles().path, mainClsName).call() } ``` @@ -78,7 +78,7 @@ There are three primary kinds of *Tasks* that you should care about: ### Targets ```scala -def allSources = T { ls.rec(sourceRoot().path).map(PathRef(_)) } +def allSources = T { os.walk(sourceRoot().path).map(PathRef(_)) } ``` `Target`s are defined using the `def foo = T {...}` syntax, and dependencies on @@ -127,7 +127,7 @@ within a `Module` body. ### Sources ```scala -def sourceRootPath = pwd / 'src +def sourceRootPath = os.pwd / 'src def sourceRoots = T.sources { sourceRootPath } ``` @@ -143,7 +143,7 @@ override-and-extend source lists the same way you would any other `T {...}` definition: ```scala -def additionalSources = T.sources { pwd / 'additionalSources } +def additionalSources = T.sources { os.pwd / 'additionalSources } def sourceRoots = T.sources { super.sourceRoots() ++ additionalSources() } ``` @@ -151,7 +151,7 @@ def sourceRoots = T.sources { super.sourceRoots() ++ additionalSources() } ```scala def run(mainClsName: String) = T.command { - %%('java, "-cp", classFiles().path, mainClsName) + os.proc('java, "-cp", classFiles().path, mainClsName).call() } ``` @@ -288,7 +288,7 @@ affect your build. For example, if I have a [Target](#targets) `bar` that makes use of the current git version: ```scala -def bar = T { ... %%("git", "rev-parse", "HEAD").out.string ... } +def bar = T { ... os.proc("git", "rev-parse", "HEAD").call().out.string ... } ``` `bar` will not know that `git rev-parse` can change, and will @@ -299,7 +299,7 @@ be out of date! To fix this, you can wrap your `git rev-parse HEAD` in a `T.input`: ```scala -def foo = T.input { %%("git", "rev-parse", "HEAD").out.string } +def foo = T.input { os.proc("git", "rev-parse", "HEAD").call().out.string } def bar = T { ... foo() ... } ``` diff --git a/docs/pages/9 - Contrib Modules.md b/docs/pages/9 - Contrib Modules.md index cd02f2c2..e071d59c 100644 --- a/docs/pages/9 - Contrib Modules.md +++ b/docs/pages/9 - Contrib Modules.md @@ -244,7 +244,7 @@ object app extends ScalaModule with TwirlModule { def twirlVersion = "1.3.15" override def generatedSources = T{ val classes = compileTwirl().classes - Seq(classes.copy(path = classes.path / up)) // we just move one dir up + Seq(classes.copy(path = classes.path / os.up)) // we just move one dir up } } ``` -- cgit v1.2.3