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 --- .../resources/examples/foreign/conflict/build.sc | 3 +- .../examples/foreign/conflict/inner/build.sc | 3 +- .../test/resources/examples/foreign/outer/build.sc | 3 +- .../examples/foreign/outer/inner/build.sc | 3 +- .../resources/examples/foreign/project/build.sc | 33 +++++++++++----------- .../examples/foreign/project/inner/build.sc | 3 +- main/test/resources/examples/javac/build.sc | 5 ++-- 7 files changed, 23 insertions(+), 30 deletions(-) (limited to 'main/test/resources/examples') diff --git a/main/test/resources/examples/foreign/conflict/build.sc b/main/test/resources/examples/foreign/conflict/build.sc index d6c08b81..bedd7237 100644 --- a/main/test/resources/examples/foreign/conflict/build.sc +++ b/main/test/resources/examples/foreign/conflict/build.sc @@ -1,6 +1,5 @@ import $file.inner.{build => innerBuild} import mill._ -import ammonite.ops._ // In this build, we have a local module targeting // the 'inner sub-directory, and an imported foreign @@ -20,5 +19,5 @@ def checkDests : T[Unit] = T { } object inner extends mill.Module { - def selfDest = T { T.ctx().dest / up / up } + def selfDest = T { T.ctx().dest / os.up / os.up } } diff --git a/main/test/resources/examples/foreign/conflict/inner/build.sc b/main/test/resources/examples/foreign/conflict/inner/build.sc index 729f4f3d..81e5fc2f 100644 --- a/main/test/resources/examples/foreign/conflict/inner/build.sc +++ b/main/test/resources/examples/foreign/conflict/inner/build.sc @@ -1,4 +1,3 @@ import mill._ -import ammonite.ops._ -def selfDest = T { T.ctx().dest / up / up } +def selfDest = T { T.ctx().dest / os.up / os.up } diff --git a/main/test/resources/examples/foreign/outer/build.sc b/main/test/resources/examples/foreign/outer/build.sc index b53cca70..adef19da 100644 --- a/main/test/resources/examples/foreign/outer/build.sc +++ b/main/test/resources/examples/foreign/outer/build.sc @@ -1,13 +1,12 @@ import $file.inner.build import mill._ -import ammonite.ops._ trait PathAware extends mill.Module { def selfPath = T { millSourcePath } } trait DestAware extends mill.Module { - def selfDest = T { T.ctx().dest / up / up } + def selfDest = T { T.ctx().dest / os.up / os.up } } object sub extends PathAware with DestAware { diff --git a/main/test/resources/examples/foreign/outer/inner/build.sc b/main/test/resources/examples/foreign/outer/inner/build.sc index 2d978292..da103b95 100644 --- a/main/test/resources/examples/foreign/outer/inner/build.sc +++ b/main/test/resources/examples/foreign/outer/inner/build.sc @@ -1,12 +1,11 @@ import mill._ -import ammonite.ops._ trait PathAware extends mill.Module { def selfPath = T { millSourcePath } } trait DestAware extends mill.Module { - def selfDest = T { T.ctx().dest / up / up } + def selfDest = T { T.ctx().dest / os.up / os.up } } object sub extends PathAware with DestAware { diff --git a/main/test/resources/examples/foreign/project/build.sc b/main/test/resources/examples/foreign/project/build.sc index 80c2af9b..54686c2d 100644 --- a/main/test/resources/examples/foreign/project/build.sc +++ b/main/test/resources/examples/foreign/project/build.sc @@ -1,10 +1,9 @@ import $file.^.outer.build import $file.inner.build -import ammonite.ops._ import mill._ -def assertPaths(p1 : Path, p2 : Path) : Unit = if (p1 != p2) throw new Exception( +def assertPaths(p1 : os.Path, p2 : os.Path) : Unit = if (p1 != p2) throw new Exception( s"Paths were not equal : \n- $p1 \n- $p2" ) @@ -17,7 +16,7 @@ object sub extends PathAware with DestAware { } def checkProjectPaths = T { - val thisPath : Path = millSourcePath + val thisPath : os.Path = millSourcePath assert(thisPath.last == "project") assertPaths(sub.selfPath(), thisPath / 'sub) assertPaths(sub.sub.selfPath(), thisPath / 'sub / 'sub) @@ -25,47 +24,47 @@ def checkProjectPaths = T { } def checkInnerPaths = T { - val thisPath : Path = millSourcePath + val thisPath : os.Path = millSourcePath assertPaths(inner.build.millSourcePath, thisPath / 'inner ) assertPaths(inner.build.sub.selfPath(), thisPath / 'inner / 'sub) assertPaths(inner.build.sub.sub.selfPath(), thisPath / 'inner / 'sub / 'sub) } def checkOuterPaths = T { - val thisPath : Path = millSourcePath - assertPaths(^.outer.build.millSourcePath, thisPath / up / 'outer ) - assertPaths(^.outer.build.sub.selfPath(), thisPath / up / 'outer / 'sub) - assertPaths(^.outer.build.sub.sub.selfPath(), thisPath / up / 'outer / 'sub / 'sub) + val thisPath : os.Path = millSourcePath + assertPaths(^.outer.build.millSourcePath, thisPath / os.up / 'outer ) + assertPaths(^.outer.build.sub.selfPath(), thisPath / os.up / 'outer / 'sub) + assertPaths(^.outer.build.sub.sub.selfPath(), thisPath / os.up / 'outer / 'sub / 'sub) } def checkOuterInnerPaths = T { - val thisPath : Path = millSourcePath - assertPaths(^.outer.inner.build.millSourcePath, thisPath / up / 'outer / 'inner ) - assertPaths(^.outer.inner.build.sub.selfPath(), thisPath / up / 'outer / 'inner /'sub) - assertPaths(^.outer.inner.build.sub.sub.selfPath(), thisPath / up / 'outer / 'inner / 'sub / 'sub) + val thisPath : os.Path = millSourcePath + assertPaths(^.outer.inner.build.millSourcePath, thisPath / os.up / 'outer / 'inner ) + assertPaths(^.outer.inner.build.sub.selfPath(), thisPath / os.up / 'outer / 'inner /'sub) + assertPaths(^.outer.inner.build.sub.sub.selfPath(), thisPath / os.up / 'outer / 'inner / 'sub / 'sub) } def checkProjectDests = T { - val outPath : Path = millSourcePath / 'out + val outPath : os.Path = millSourcePath / 'out assertPaths(sub.selfDest(), outPath / 'sub) assertPaths(sub.sub.selfDest(), outPath / 'sub / 'sub) assertPaths(sub.sub2.selfDest(), outPath / 'sub / 'sub2) } def checkInnerDests = T { - val foreignOut : Path = millSourcePath / 'out / "foreign-modules" + val foreignOut : os.Path = millSourcePath / 'out / "foreign-modules" assertPaths(inner.build.sub.selfDest(), foreignOut / 'inner / 'sub) assertPaths(inner.build.sub.sub.selfDest(), foreignOut / 'inner / 'sub / 'sub) } def checkOuterDests = T { - val foreignOut : Path = millSourcePath / 'out / "foreign-modules" + val foreignOut : os.Path = millSourcePath / 'out / "foreign-modules" assertPaths(^.outer.build.sub.selfDest(), foreignOut / "up-1" / 'outer/ 'sub ) assertPaths(^.outer.build.sub.sub.selfDest(), foreignOut / "up-1" / 'outer/ 'sub / 'sub) } def checkOuterInnerDests = T { - val foreignOut : Path = millSourcePath / 'out / "foreign-modules" + val foreignOut : os.Path = millSourcePath / 'out / "foreign-modules" assertPaths(^.outer.inner.build.sub.selfDest(), foreignOut / "up-1" / 'outer/ 'inner / 'sub) assertPaths(^.outer.inner.build.sub.sub.selfDest(), foreignOut / "up-1" / 'outer/ 'inner / 'sub / 'sub) } @@ -77,6 +76,6 @@ trait PathAware extends mill.Module { } trait DestAware extends mill.Module { - def selfDest = T { T.ctx().dest / up / up } + def selfDest = T { T.ctx().dest / os.up / os.up } } diff --git a/main/test/resources/examples/foreign/project/inner/build.sc b/main/test/resources/examples/foreign/project/inner/build.sc index 2d978292..da103b95 100644 --- a/main/test/resources/examples/foreign/project/inner/build.sc +++ b/main/test/resources/examples/foreign/project/inner/build.sc @@ -1,12 +1,11 @@ import mill._ -import ammonite.ops._ trait PathAware extends mill.Module { def selfPath = T { millSourcePath } } trait DestAware extends mill.Module { - def selfDest = T { T.ctx().dest / up / up } + def selfDest = T { T.ctx().dest / os.up / os.up } } object sub extends PathAware with DestAware { diff --git a/main/test/resources/examples/javac/build.sc b/main/test/resources/examples/javac/build.sc index 0783ac17..c45a6e2d 100644 --- a/main/test/resources/examples/javac/build.sc +++ b/main/test/resources/examples/javac/build.sc @@ -1,4 +1,3 @@ -import ammonite.ops._ import mill.T import mill.eval.JavaCompileJarTests.compileAll import mill.eval.PathRef @@ -14,10 +13,10 @@ def resourceRootPath = millSourcePath / 'resources // resourceRoot ----> jar def sourceRoot = T.sources{ sourceRootPath } def resourceRoot = T.sources{ resourceRootPath } -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{ compileAll(allSources()) } def jar = T{ Jvm.createJar(Loose.Agg(classFiles().path) ++ resourceRoot().map(_.path)) } def run(mainClsName: String) = T.command{ - %%('java, "-cp", classFiles().path, mainClsName)(T.ctx().dest) + os.proc('java, "-cp", classFiles().path, mainClsName).call(T.ctx().dest) } -- cgit v1.2.3