summaryrefslogtreecommitdiff
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
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
-rw-r--r--.appveyor.yml4
-rwxr-xr-xbuild.sc2
-rw-r--r--contrib/buildinfo/src/mill/contrib/BuildInfo.scala3
-rw-r--r--contrib/buildinfo/test/src/mill/contrib/BuildInfoTests.scala27
-rw-r--r--contrib/scalapblib/src/mill/contrib/scalapblib/ScalaPBWorker.scala11
-rw-r--r--contrib/scalapblib/test/src/mill/contrib/scalapblib/TutorialTests.scala21
-rw-r--r--contrib/tut/src/mill/contrib/tut/TutModule.scala9
-rw-r--r--contrib/tut/test/src/mill/contrib/tut/TutTests.scala29
-rw-r--r--contrib/twirllib/src/mill/twirllib/TwirlWorker.scala17
-rw-r--r--contrib/twirllib/test/src/mill/twirllib/HelloWorldTests.scala19
-rw-r--r--docs/build.sc20
-rw-r--r--docs/logo.sc2
-rw-r--r--docs/pages/2 - Configuring Mill.md4
-rw-r--r--docs/pages/4 - Tasks.md26
-rw-r--r--docs/pages/9 - Contrib Modules.md2
-rw-r--r--integration/test/resources/ammonite/build.sc4
-rw-r--r--integration/test/resources/jawn/build.sc5
-rw-r--r--integration/test/resources/play-json/build.sc36
-rw-r--r--integration/test/resources/play-json/headers.sc10
-rw-r--r--integration/test/resources/play-json/jmh.sc16
-rw-r--r--integration/test/resources/play-json/mima.sc4
-rw-r--r--integration/test/resources/play-json/reformat.sc12
-rwxr-xr-xintegration/test/resources/play-json/release.sh2
-rw-r--r--integration/test/resources/upickle/build.sc2
-rw-r--r--integration/test/src/mill/integration/AcyclicTests.scala9
-rw-r--r--integration/test/src/mill/integration/AmmoniteTests.scala5
-rw-r--r--integration/test/src/mill/integration/BetterFilesTests.scala5
-rw-r--r--integration/test/src/mill/integration/DocAnnotationsTests.scala3
-rw-r--r--integration/test/src/mill/integration/IntegrationTestSuite.scala11
-rw-r--r--integration/test/src/mill/integration/JawnTests.scala9
-rw-r--r--integration/test/src/mill/integration/PlayJsonTests.scala6
-rw-r--r--integration/test/src/mill/integration/UpickleTests.scala1
-rw-r--r--main/core/src/mill/define/BaseModule.scala3
-rw-r--r--main/core/src/mill/define/Ctx.scala6
-rw-r--r--main/core/src/mill/define/Module.scala3
-rw-r--r--main/core/src/mill/define/Task.scala4
-rw-r--r--main/core/src/mill/eval/Evaluator.scala50
-rw-r--r--main/core/src/mill/eval/PathRef.scala37
-rw-r--r--main/core/src/mill/util/ClassLoader.scala2
-rw-r--r--main/core/src/mill/util/Ctx.scala11
-rw-r--r--main/core/src/mill/util/JsonFormatters.scala15
-rw-r--r--main/core/src/mill/util/Logger.scala7
-rw-r--r--main/core/src/mill/util/Scripts.scala14
-rw-r--r--main/graphviz/src/mill/main/graphviz/GraphvizTools.scala3
-rw-r--r--main/src/mill/MillMain.scala7
-rw-r--r--main/src/mill/main/MainModule.scala7
-rw-r--r--main/src/mill/main/MainRunner.scala9
-rw-r--r--main/src/mill/main/ReplApplyHandler.scala3
-rw-r--r--main/src/mill/main/RunScript.scala19
-rw-r--r--main/src/mill/main/VisualizeModule.scala5
-rw-r--r--main/src/mill/modules/Assembly.scala17
-rw-r--r--main/src/mill/modules/Jvm.scala131
-rw-r--r--main/src/mill/modules/Util.scala21
-rw-r--r--main/test/resources/examples/foreign/conflict/build.sc3
-rw-r--r--main/test/resources/examples/foreign/conflict/inner/build.sc3
-rw-r--r--main/test/resources/examples/foreign/outer/build.sc3
-rw-r--r--main/test/resources/examples/foreign/outer/inner/build.sc3
-rw-r--r--main/test/resources/examples/foreign/project/build.sc33
-rw-r--r--main/test/resources/examples/foreign/project/inner/build.sc3
-rw-r--r--main/test/resources/examples/javac/build.sc5
-rw-r--r--main/test/src/mill/UTestFramework.scala4
-rw-r--r--main/test/src/mill/define/BasePathTests.scala9
-rw-r--r--main/test/src/mill/define/CacherTests.scala1
-rw-r--r--main/test/src/mill/eval/CrossTests.scala2
-rw-r--r--main/test/src/mill/eval/EvaluationTests.scala2
-rw-r--r--main/test/src/mill/eval/FailureTests.scala1
-rw-r--r--main/test/src/mill/eval/JavaCompileJarTests.scala35
-rw-r--r--main/test/src/mill/eval/ModuleTests.scala10
-rw-r--r--main/test/src/mill/eval/TaskTests.scala14
-rw-r--r--main/test/src/mill/main/ClientServerTests.scala5
-rw-r--r--main/test/src/mill/main/ForeignBuildsTest.scala5
-rw-r--r--main/test/src/mill/main/ForeignConflictTest.scala6
-rw-r--r--main/test/src/mill/main/JavaCompileJarTests.scala15
-rw-r--r--main/test/src/mill/util/ScriptTestSuite.scala19
-rw-r--r--main/test/src/mill/util/TestEvaluator.scala3
-rw-r--r--main/test/src/mill/util/TestUtil.scala9
-rw-r--r--readme.md2
-rw-r--r--scalajslib/src/mill/scalajslib/ScalaJSModule.scala9
-rw-r--r--scalajslib/src/mill/scalajslib/ScalaJSWorkerApi.scala19
-rw-r--r--scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala16
-rw-r--r--scalajslib/test/src/mill/scalajslib/MultiModuleTests.scala11
-rw-r--r--scalajslib/test/src/mill/scalajslib/NodeJSConfigTests.scala11
-rw-r--r--scalajslib/test/src/mill/scalajslib/ScalaJsUtils.scala4
-rw-r--r--scalalib/src/mill/scalalib/GenIdeaImpl.scala87
-rw-r--r--scalalib/src/mill/scalalib/JavaModule.scala42
-rw-r--r--scalalib/src/mill/scalalib/Lib.scala15
-rw-r--r--scalalib/src/mill/scalalib/MiscModule.scala3
-rw-r--r--scalalib/src/mill/scalalib/PublishModule.scala7
-rw-r--r--scalalib/src/mill/scalalib/ScalaModule.scala7
-rw-r--r--scalalib/src/mill/scalalib/TestRunner.scala13
-rw-r--r--scalalib/src/mill/scalalib/ZincWorkerApi.scala22
-rw-r--r--scalalib/src/mill/scalalib/dependency/versions/VersionsFinder.scala3
-rw-r--r--scalalib/src/mill/scalalib/publish/LocalPublisher.scala19
-rw-r--r--scalalib/src/mill/scalalib/publish/SonatypePublisher.scala18
-rw-r--r--scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala7
-rw-r--r--scalalib/src/mill/scalalib/scalafmt/ScalafmtWorker.scala13
-rw-r--r--scalalib/test/src/mill/scalalib/GenIdeaTests.scala7
-rw-r--r--scalalib/test/src/mill/scalalib/HelloJavaTests.scala24
-rw-r--r--scalalib/test/src/mill/scalalib/HelloWorldTests.scala110
-rw-r--r--scalalib/test/src/mill/scalalib/scalafmt/ScalafmtTests.scala23
-rw-r--r--scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala49
-rw-r--r--scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala3
-rw-r--r--scalanativelib/src/mill/scalanativelib/ScalaNativeWorkerApi.scala23
-rw-r--r--scalanativelib/test/src/mill/scalanativelib/HelloNativeWorldTests.scala15
-rw-r--r--scalanativelib/worker/0.3/src/mill/scalanativelib/worker/ScalaNativeWorkerImpl.scala19
105 files changed, 708 insertions, 796 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index 1bd0c4c7..4cd5bfa0 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -33,7 +33,7 @@ build_script:
cmd /C C:\mill\out\release\dest\mill.bat -i all main.test scalajslib.test)
- if [%COMPILER%]==[msys2] (
SET "PATH=%JAVA_HOME%\bin;C:\%MSYS2_DIR%\%MSYSTEM%\bin;C:\%MSYS2_DIR%\usr\bin;%PATH%" &&
- C:\%MSYS2_DIR%\usr\bin\bash -lc 'mkdir -p /usr/local/bin' &&
+ C:\%MSYS2_DIR%\usr\bin\bash -lc 'os.makeDir.all -p /usr/local/bin' &&
C:\%MSYS2_DIR%\usr\bin\bash -lc "curl -Lo /usr/local/bin/mill %MILL_URL%" &&
C:\%MSYS2_DIR%\usr\bin\bash -lc 'chmod +x /usr/local/bin/mill' &&
C:\%MSYS2_DIR%\usr\bin\bash -lc "cd /c/mill && mill -i dev.assembly" &&
@@ -41,7 +41,7 @@ build_script:
C:\%MSYS2_DIR%\usr\bin\bash -lc "cd /c/mill && out/dev/assembly/dest/mill.bat -i all main.test scalajslib.test")
- if [%COMPILER%]==[cygwin] (
SET "PATH=%JAVA_HOME%\bin;C:\%CYGWIN_DIR%\bin;C:\%CYGWIN_DIR%\usr\bin;%PATH%" &&
- C:\%CYGWIN_DIR%\bin\bash -lc 'mkdir -p /usr/local/bin' &&
+ C:\%CYGWIN_DIR%\bin\bash -lc 'os.makeDir.all -p /usr/local/bin' &&
C:\%CYGWIN_DIR%\bin\bash -lc "curl -Lo /usr/local/bin/mill %MILL_URL%" &&
C:\%CYGWIN_DIR%\bin\bash -lc 'sed -i '"'"'0,/-cp "\$0"/{s/-cp "\$0"/-cp `cygpath -w "\$0"`/}; 0,/-cp "\$0"/{s/-cp "\$0"/-cp `cygpath -w "\$0"`/}'"'"' /usr/local/bin/mill' &&
C:\%CYGWIN_DIR%\bin\bash -lc 'chmod +x /usr/local/bin/mill' &&
diff --git a/build.sc b/build.sc
index 969a3287..8e4b1b13 100755
--- a/build.sc
+++ b/build.sc
@@ -88,7 +88,7 @@ object main extends MillModule {
def ivyDeps = Agg(
// Keep synchronized with ammonite in Versions.scala
- ivy"com.lihaoyi:::ammonite:1.3.3",
+ ivy"com.lihaoyi:::ammonite:1.4.0",
// Necessary so we can share the JNA classes throughout the build process
ivy"net.java.dev.jna:jna:4.5.0",
ivy"net.java.dev.jna:jna-platform:4.5.0"
diff --git a/contrib/buildinfo/src/mill/contrib/BuildInfo.scala b/contrib/buildinfo/src/mill/contrib/BuildInfo.scala
index 0eb94a6d..9202fd95 100644
--- a/contrib/buildinfo/src/mill/contrib/BuildInfo.scala
+++ b/contrib/buildinfo/src/mill/contrib/BuildInfo.scala
@@ -1,6 +1,5 @@
package mill.contrib
-import ammonite.ops.write
import mill.T
import mill.define.Target
import mill.eval.PathRef
@@ -26,7 +25,7 @@ trait BuildInfo extends ScalaModule {
case (name, value) => s""" def ${name} = "${value}""""
}
.mkString("\n")
- write(outputFile,
+ os.write(outputFile,
s"""|${buildInfoPackageName.map(p => s"package ${p}").getOrElse("")}
|object ${buildInfoObjectName} {
|$internalMembers
diff --git a/contrib/buildinfo/test/src/mill/contrib/BuildInfoTests.scala b/contrib/buildinfo/test/src/mill/contrib/BuildInfoTests.scala
index e2147bac..05070985 100644
--- a/contrib/buildinfo/test/src/mill/contrib/BuildInfoTests.scala
+++ b/contrib/buildinfo/test/src/mill/contrib/BuildInfoTests.scala
@@ -1,6 +1,5 @@
package mill.contrib
-import ammonite.ops._
import java.util.jar.JarFile
import mill._
import mill.define.Target
@@ -43,16 +42,16 @@ object BuildInfoTests extends TestSuite {
}
}
- val resourcePath = pwd / 'contrib / 'buildinfo / 'test / 'resources / "buildinfo"
+ val resourcePath = os.pwd / 'contrib / 'buildinfo / 'test / 'resources / "buildinfo"
- 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)
}
@@ -68,8 +67,8 @@ object BuildInfoTests extends TestSuite {
val Right((result, evalCount)) = eval.apply(BuildInfo.buildInfo)
assert(
result.head.path == eval.outPath / 'buildInfo / 'dest / "BuildInfo.scala" &&
- exists(result.head.path) &&
- read! result.head.path == expected
+ os.exists(result.head.path) &&
+ os.read(result.head.path) == expected
)
}
@@ -77,7 +76,7 @@ object BuildInfoTests extends TestSuite {
val Right((result, evalCount)) = eval.apply(EmptyBuildInfo.buildInfo)
assert(
result.isEmpty &&
- !exists(eval.outPath / 'buildInfo / 'dest / "BuildInfo.scala")
+ !os.exists(eval.outPath / 'buildInfo / 'dest / "BuildInfo.scala")
)
}
@@ -90,8 +89,8 @@ object BuildInfoTests extends TestSuite {
val Right((result, evalCount)) = eval.apply(BuildInfoSettings.buildInfo)
assert(
result.head.path == eval.outPath / 'buildInfo / 'dest / "BuildInfo.scala" &&
- exists(result.head.path) &&
- read! result.head.path == expected
+ os.exists(result.head.path) &&
+ os.read(result.head.path) == expected
)
}
@@ -104,8 +103,8 @@ object BuildInfoTests extends TestSuite {
val runResult = eval.outPath / "hello-mill"
val Right((result, evalCount)) = eval.apply(BuildInfo.run(runResult.toString))
assert(
- exists(runResult),
- read(runResult) == scalaVersionString)
+ os.exists(runResult),
+ os.read(runResult) == scalaVersionString)
}
}
}
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 / _)
diff --git a/contrib/tut/src/mill/contrib/tut/TutModule.scala b/contrib/tut/src/mill/contrib/tut/TutModule.scala
index f051a465..e51a8d7b 100644
--- a/contrib/tut/src/mill/contrib/tut/TutModule.scala
+++ b/contrib/tut/src/mill/contrib/tut/TutModule.scala
@@ -1,7 +1,6 @@
package mill
package contrib.tut
-import ammonite.ops._
import coursier.MavenRepository
import mill.scalalib._
import scala.util.matching.Regex
@@ -51,7 +50,7 @@ trait TutModule extends ScalaModule {
* A task which determines where the compiled documentation files will be placed. By default this is simply the Mill build's output folder for this task,
* but this can be reconfigured so that documentation goes to the root of the module (e.g. `millSourcePath`) or to a dedicated folder (e.g. `millSourcePath / 'docs`)
*/
- def tutTargetDirectory: T[Path] = T { T.ctx().dest }
+ def tutTargetDirectory: T[os.Path] = T { T.ctx().dest }
/**
* A task which determines what classpath is used when compiling documentation. By default this is configured to use the same inputs as the [[mill.contrib.tut.TutModule#runClasspath]],
@@ -115,18 +114,18 @@ trait TutModule extends ScalaModule {
/**
* Run Tut using the configuration specified in this module. The working directory used is the [[mill.contrib.tut.TutModule#millSourcePath]].
*/
- def tut: T[CommandResult] = T {
+ def tut: T[os.CommandResult] = T {
val in = tutSourceDirectory().head.path.toIO.getAbsolutePath
val out = tutTargetDirectory().toIO.getAbsolutePath
val re = tutNameFilter()
val opts = tutScalacOptions()
val pOpts = tutPluginJars().map(pathRef => "-Xplugin:" + pathRef.path.toIO.getAbsolutePath)
val tutArgs = List(in, out, re.pattern.toString) ++ opts ++ pOpts
- %%(
+ os.proc(
'java,
"-cp", tutClasspath().map(_.path.toIO.getAbsolutePath).mkString(java.io.File.pathSeparator),
"tut.TutMain",
tutArgs
- )(wd = millSourcePath)
+ ).call(millSourcePath)
}
}
diff --git a/contrib/tut/test/src/mill/contrib/tut/TutTests.scala b/contrib/tut/test/src/mill/contrib/tut/TutTests.scala
index fd369eed..8168930f 100644
--- a/contrib/tut/test/src/mill/contrib/tut/TutTests.scala
+++ b/contrib/tut/test/src/mill/contrib/tut/TutTests.scala
@@ -1,7 +1,6 @@
package mill.contrib
package tut
-import ammonite.ops._
import mill._
import mill.eval.Result._
import mill.scalalib._
@@ -29,17 +28,17 @@ object TutTests extends TestSuite {
def scalacPluginIvyDeps = Agg(ivy"org.spire-math::kind-projector:0.9.8")
}
- val resourcePath = pwd / 'contrib / 'tut / 'test / 'tut
- val resourcePathWithLibraries = pwd / 'contrib / 'tut / 'test / "tut-with-libraries"
+ val resourcePath = os.pwd / 'contrib / 'tut / 'test / 'tut
+ val resourcePathWithLibraries = os.pwd / 'contrib / 'tut / 'test / "tut-with-libraries"
- 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)
- cp(resourcePath, m.millSourcePath / 'tut)
+ os.remove.all(m.millSourcePath)
+ os.remove.all(eval.outPath)
+ os.makeDir.all(m.millSourcePath)
+ os.copy(resourcePath, m.millSourcePath / 'tut)
t(eval)
}
@@ -61,8 +60,8 @@ object TutTests extends TestSuite {
val Right((result, evalCount)) = eval.apply(TutTest.tut)
assert(
- exists(expectedPath) &&
- read! expectedPath == expected
+ os.exists(expectedPath) &&
+ os.read(expectedPath) == expected
)
}
@@ -84,9 +83,9 @@ object TutTests extends TestSuite {
val Right((result, evalCount)) = eval.apply(TutCustomTest.tut)
assert(
- !exists(defaultPath) &&
- exists(expectedPath) &&
- read! expectedPath == expected
+ !os.exists(defaultPath) &&
+ os.exists(expectedPath) &&
+ os.read(expectedPath) == expected
)
}
@@ -115,8 +114,8 @@ object TutTests extends TestSuite {
val Right(_) = eval.apply(TutLibrariesTest.tut)
assert(
- exists(expectedPath) &&
- read! expectedPath == expected
+ os.exists(expectedPath) &&
+ os.read(expectedPath) == expected
)
}
}
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 / _
)
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
}
}
```
diff --git a/integration/test/resources/ammonite/build.sc b/integration/test/resources/ammonite/build.sc
index c26d5050..34f80825 100644
--- a/integration/test/resources/ammonite/build.sc
+++ b/integration/test/resources/ammonite/build.sc
@@ -65,8 +65,8 @@ object amm extends Cross[MainModule](fullCrossScalaVersions:_*){
)
def generatedSources = T{
- import ammonite.ops._
- cp(build.millSourcePath/'project/"Constants.scala", T.ctx().dest/"Constants.scala")
+
+ os.copy(build.millSourcePath/'project/"Constants.scala", T.ctx().dest/"Constants.scala")
Seq(PathRef(T.ctx().dest))
}
}
diff --git a/integration/test/resources/jawn/build.sc b/integration/test/resources/jawn/build.sc
index deb9731a..8b58efc7 100644
--- a/integration/test/resources/jawn/build.sc
+++ b/integration/test/resources/jawn/build.sc
@@ -1,10 +1,9 @@
import mill.scalalib
import mill.Cross
import mill.scalalib.{Dep, TestModule, DepSyntax, Lib}
-import ammonite.ops.up
object jawn extends Cross[JawnModule]("2.10.6", "2.11.11", "2.12.3")
class JawnModule(crossVersion: String) extends mill.Module{
- override def millSourcePath = super.millSourcePath / up / up
+ override def millSourcePath = super.millSourcePath / os.up / os.up
trait JawnModule extends scalalib.SbtModule{
def scalaVersion = crossVersion
@@ -53,7 +52,7 @@ class JawnModule(crossVersion: String) extends mill.Module{
object rojoma extends Support(ivy"com.rojoma::rojoma-json:2.4.3")
object rojomaV3 extends Support(ivy"com.rojoma::rojoma-json-v3:3.7.2"){
- override def millSourcePath = super.millSourcePath / up / "rojoma-v3"
+ override def millSourcePath = super.millSourcePath / os.up / "rojoma-v3"
}
object spray extends Support(ivy"io.spray::spray-json:1.3.3")
}
diff --git a/integration/test/resources/play-json/build.sc b/integration/test/resources/play-json/build.sc
index d4557011..54e63d65 100644
--- a/integration/test/resources/play-json/build.sc
+++ b/integration/test/resources/play-json/build.sc
@@ -10,7 +10,7 @@ import jmh.Jmh
import headers.Headers
import com.typesafe.tools.mima.core._
-import ammonite.ops._
+
import mill.define.Task
val ScalaVersions = Seq("2.10.7", "2.11.12", "2.12.4", "2.13.0-M3")
@@ -52,7 +52,7 @@ trait PlayJsonModule extends BaseModule with PublishModule with MiMa {
abstract class PlayJson(val platformSegment: String) extends PlayJsonModule {
def crossScalaVersion: String
- def millSourcePath = pwd / "play-json"
+ def millSourcePath = os.pwd / "play-json"
def artifactName = "play-json"
def sources = T.sources(
@@ -90,10 +90,10 @@ abstract class PlayJson(val platformSegment: String) extends PlayJsonModule {
)
def generatedSources = T {
- import ammonite.ops._
+
val dir = T.ctx().dest
- mkdir(dir / "play-json")
+ os.makeDir.all(dir / "play-json")
val file = dir / "play-json" / "Generated.scala"
val (writes, reads) = (1 to 22).map { i =>
@@ -126,7 +126,7 @@ abstract class PlayJson(val platformSegment: String) extends PlayJsonModule {
""")
}.unzip
- write(file, s"""
+ os.write(file, s"""
package play.api.libs.json
trait GeneratedReads {
@@ -168,7 +168,11 @@ class PlayJsonJvm(val crossScalaVersion: String) extends PlayJson("jvm") {
)
def sources = {
- val docSpecs = ls.rec(millSourcePath / up / "docs" / "manual" / "working" / "scalaGuide").filter(_.isDir).filter(_.last=="code").map(PathRef(_))
+ val docSpecs = os.walk(millSourcePath / os.up / "docs" / "manual" / "working" / "scalaGuide")
+ .filter(os.isDir)
+ .filter(_.last=="code")
+ .map(PathRef(_))
+
T.sources(
docSpecs ++
Seq(
@@ -213,7 +217,7 @@ class PlayJsonJs(val crossScalaVersion: String) extends PlayJson("js") with Scal
}
trait PlayFunctional extends PlayJsonModule {
- def millSourcePath = pwd / "play-functional"
+ def millSourcePath = os.pwd / "play-functional"
def artifactName = "play-functional"
}
@@ -229,7 +233,7 @@ object playJoda extends Cross[PlayJoda](ScalaVersions:_*)
class PlayJoda(val crossScalaVersion: String) extends PlayJsonModule {
def moduleDeps = Seq(playJsonJvm(crossScalaVersion))
- def millSourcePath = pwd / "play-json-joda"
+ def millSourcePath = os.pwd / "play-json-joda"
def artifactName = "play-json-joda"
def ivyDeps = Agg(
@@ -250,7 +254,7 @@ object benchmarks extends Cross[Benchmarks](ScalaVersions:_*)
class Benchmarks(val crossScalaVersion: String) extends BaseModule with Jmh {
def moduleDeps = Seq(playJsonJvm(crossScalaVersion))
- def millSourcePath = pwd / "benchmarks"
+ def millSourcePath = os.pwd / "benchmarks"
}
// TODO: we should have a way to "take all modules in this build"
@@ -322,7 +326,7 @@ def validateCode() = T.command {
*/
object release extends Module {
- implicit val wd = pwd
+ implicit val wd = os.pwd
val versionFile = wd / "version.sc"
@@ -345,27 +349,27 @@ object release extends Module {
def setReleaseVersion = T {
T.ctx.log.info(s"Setting release version to ${releaseVersion}")
- write.over(
+ os.write.over(
versionFile,
s"""def current = "${releaseVersion}"
|
""".stripMargin
)
- %%("git", "commit", "-am", s"Setting release version to ${releaseVersion}")
- %%("git", "tag", s"$releaseVersion")
+ os.proc("git", "commit", "-am", s"Setting release version to ${releaseVersion}").call()
+ os.proc("git", "tag", s"$releaseVersion").call()
}
def setNextVersion = T {
T.ctx.log.info(s"Setting next version to ${nextVersion}")
- write.over(
+ os.write.over(
versionFile,
s"""def current = "${nextVersion}""""
)
- %%("git", "commit", "-am", s"Setting next version to ${nextVersion}")
- %%("git", "push", "origin", "master", "--tags")
+ os.proc("git", "commit", "-am", s"Setting next version to ${nextVersion}").call()
+ os.proc("git", "push", "origin", "master", "--tags").call()
}
}
diff --git a/integration/test/resources/play-json/headers.sc b/integration/test/resources/play-json/headers.sc
index a66eaedd..9737cb3d 100644
--- a/integration/test/resources/play-json/headers.sc
+++ b/integration/test/resources/play-json/headers.sc
@@ -1,6 +1,6 @@
import $ivy.`com.github.rockjam::license-headers:0.0.1`
-import ammonite.ops._
+
import mill._, scalalib._
import mill.eval.PathRef
import de.heikoseeberger.sbtheader.{CommentStyle, FileType, HeaderCreator, License}
@@ -24,7 +24,7 @@ trait Headers extends ScalaModule {
val updatedFiles = withoutHeaders.map {
case (file, updated) =>
- write.over(file, updated)
+ os.write.over(file, updated)
file
}
@@ -47,15 +47,15 @@ trait Headers extends ScalaModule {
private def filesWithoutHeaders(input: Seq[PathRef]) = {
for {
- ref <- input if exists(ref.path)
- file <- ls.rec(ref.path) if file.isFile
+ ref <- input if os.exists(ref.path)
+ file <- os.walk(ref.path) if os.isFile(file)
(fileType, commentStyle) <- headerMappings.get(file.ext)
updatedContent <- HeaderCreator(
fileType,
commentStyle,
license,
log = _ => (),
- read.getInputStream(file)
+ os.read.inputStream(file)
).createText
} yield file -> updatedContent
}
diff --git a/integration/test/resources/play-json/jmh.sc b/integration/test/resources/play-json/jmh.sc
index 76ed43fc..3c2c8411 100644
--- a/integration/test/resources/play-json/jmh.sc
+++ b/integration/test/resources/play-json/jmh.sc
@@ -1,4 +1,4 @@
-import ammonite.ops._
+
import mill._, scalalib._, modules._
trait Jmh extends ScalaModule {
@@ -19,13 +19,13 @@ trait Jmh extends ScalaModule {
def compileGeneratedSources = T {
val dest = T.ctx.dest
val (sourcesDir, _) = generateBenchmarkSources()
- val sources = ls.rec(sourcesDir).filter(_.isFile)
- %%("javac",
+ val sources = os.walk(sourcesDir).filter(os.isFile)
+ os.proc("javac",
sources.map(_.toString),
"-cp",
(runClasspath() ++ generatorDeps()).map(_.path.toString).mkString(":"),
"-d",
- dest)(wd = dest)
+ dest).call(dest)
PathRef(dest)
}
@@ -36,10 +36,10 @@ trait Jmh extends ScalaModule {
val sourcesDir = dest / 'jmh_sources
val resourcesDir = dest / 'jmh_resources
- rm(sourcesDir)
- mkdir(sourcesDir)
- rm(resourcesDir)
- mkdir(resourcesDir)
+ os.remove.all(sourcesDir)
+ os.makeDir.all(sourcesDir)
+ os.remove.all(resourcesDir)
+ os.makeDir.all(resourcesDir)
Jvm.subprocess(
"org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator",
diff --git a/integration/test/resources/play-json/mima.sc b/integration/test/resources/play-json/mima.sc
index 3902f2c7..baca333c 100644
--- a/integration/test/resources/play-json/mima.sc
+++ b/integration/test/resources/play-json/mima.sc
@@ -1,4 +1,4 @@
-import ammonite.ops._
+
import $ivy.`com.typesafe::mima-reporter:0.1.18`
import com.typesafe.tools.mima.lib.MiMaLib
import com.typesafe.tools.mima.core._
@@ -34,7 +34,7 @@ trait MiMa extends ScalaModule with PublishModule {
com.typesafe.tools.mima.core.Config.setup("sbt-mima-plugin", Array.empty)
val cpstring = classpath
.map(_.path)
- .filter(exists)
+ .filter(os.exists)
.mkString(System.getProperty("path.separator"))
new MiMaLib(
com.typesafe.tools.mima.core.reporterClassPath(cpstring)
diff --git a/integration/test/resources/play-json/reformat.sc b/integration/test/resources/play-json/reformat.sc
index c44b2f97..3127bc5d 100644
--- a/integration/test/resources/play-json/reformat.sc
+++ b/integration/test/resources/play-json/reformat.sc
@@ -1,7 +1,7 @@
import $ivy.`org.scalariform::scalariform:0.2.5`
import mill._, scalalib._
-import ammonite.ops._
+
import scalariform.formatter._
import scalariform.formatter.preferences._
import scalariform.parser.ScalaParserException
@@ -25,11 +25,11 @@ trait Scalariform extends ScalaModule {
files.map { path =>
try {
val formatted = ScalaFormatter.format(
- read(path),
+ os.read(path),
playJsonPreferences,
scalaVersion = scalaVersion()
)
- write.over(path, formatted)
+ os.write.over(path, formatted)
} catch {
case ex: ScalaParserException =>
T.ctx.log.error(s"Failed to format file: ${path}. Error: ${ex.getMessage}")
@@ -41,7 +41,7 @@ trait Scalariform extends ScalaModule {
def checkCodeFormat() = T.command {
filesToFormat(sources()).foreach { path =>
try {
- val input = read(path)
+ val input = os.read(path)
val formatted = ScalaFormatter.format(
input,
playJsonPreferences,
@@ -63,8 +63,8 @@ trait Scalariform extends ScalaModule {
private def filesToFormat(sources: Seq[PathRef]) = {
for {
- pathRef <- sources if exists(pathRef.path)
- file <- ls.rec(pathRef.path) if file.isFile && file.ext == "scala"
+ pathRef <- sources if os.exists(pathRef.path)
+ file <- os.walk(pathRef.path) if os.isFile(file) && file.ext == "scala"
} yield file
}
diff --git a/integration/test/resources/play-json/release.sh b/integration/test/resources/play-json/release.sh
index 009300a0..6efe80ce 100755
--- a/integration/test/resources/play-json/release.sh
+++ b/integration/test/resources/play-json/release.sh
@@ -2,7 +2,7 @@
set -eux
-rm -rf out
+os.remove.all -rf out
mill __.test
mill release.setReleaseVersion
mill mill.scalalib.PublishModule/publishAll \
diff --git a/integration/test/resources/upickle/build.sc b/integration/test/resources/upickle/build.sc
index 1f5f2bed..86552d9d 100644
--- a/integration/test/resources/upickle/build.sc
+++ b/integration/test/resources/upickle/build.sc
@@ -43,7 +43,7 @@ trait UpickleModule extends CrossSbtModule with PublishModule{
def generatedSources = T{
val dir = T.ctx().dest
val file = dir / "upickle" / "Generated.scala"
- ammonite.ops.mkdir(dir / "upickle")
+ os.makeDir.all(dir / "upickle")
val tuplesAndCases = (1 to 22).map{ i =>
def commaSeparated(s: Int => String) = (1 to i).map(s).mkString(", ")
val writerTypes = commaSeparated(j => s"T$j: Writer")
diff --git a/integration/test/src/mill/integration/AcyclicTests.scala b/integration/test/src/mill/integration/AcyclicTests.scala
index c117f862..145c106d 100644
--- a/integration/test/src/mill/integration/AcyclicTests.scala
+++ b/integration/test/src/mill/integration/AcyclicTests.scala
@@ -1,6 +1,5 @@
package mill.integration
-import ammonite.ops._
import utest._
class AcyclicTests(fork: Boolean)
@@ -13,11 +12,11 @@ class AcyclicTests(fork: Boolean)
assert(
firstCompile,
- ls.rec(workspacePath).exists(_.last == "GraphAnalysis.class"),
- ls.rec(workspacePath).exists(_.last == "PluginPhase.class")
+ os.walk(workspacePath).exists(_.last == "GraphAnalysis.class"),
+ os.walk(workspacePath).exists(_.last == "PluginPhase.class")
)
- for(scalaFile <- ls.rec(workspacePath).filter(_.ext == "scala")){
- write.append(scalaFile, "\n}")
+ for(scalaFile <- os.walk(workspacePath).filter(_.ext == "scala")){
+ os.write.append(scalaFile, "\n}")
}
val brokenCompile = eval(s"acyclic[$scalaVersion].compile")
diff --git a/integration/test/src/mill/integration/AmmoniteTests.scala b/integration/test/src/mill/integration/AmmoniteTests.scala
index 3f04e84d..2f2c648d 100644
--- a/integration/test/src/mill/integration/AmmoniteTests.scala
+++ b/integration/test/src/mill/integration/AmmoniteTests.scala
@@ -1,6 +1,5 @@
package mill.integration
-import ammonite.ops._
import utest._
class AmmoniteTests(fork: Boolean)
@@ -25,8 +24,8 @@ class AmmoniteTests(fork: Boolean)
assert(
compileResult,
- ls.rec(workspacePath / 'out / 'integration / scalaVersion / 'test / 'compile)
- .exists(_.name == "ErrorTruncationTests.class")
+ os.walk(workspacePath / 'out / 'integration / scalaVersion / 'test / 'compile)
+ .exists(_.last == "ErrorTruncationTests.class")
)
}
diff --git a/integration/test/src/mill/integration/BetterFilesTests.scala b/integration/test/src/mill/integration/BetterFilesTests.scala
index 4f3116f7..bdbaa2e3 100644
--- a/integration/test/src/mill/integration/BetterFilesTests.scala
+++ b/integration/test/src/mill/integration/BetterFilesTests.scala
@@ -1,6 +1,5 @@
package mill.integration
-import ammonite.ops._
import utest._
class BetterFilesTests(fork: Boolean)
@@ -17,8 +16,8 @@ class BetterFilesTests(fork: Boolean)
assert(coreTestMeta.contains("better.files.FileSpec"))
assert(coreTestMeta.contains("files should handle BOM"))
- for(scalaFile <- ls.rec(workspacePath).filter(_.ext == "scala")){
- write.append(scalaFile, "\n}")
+ for(scalaFile <- os.walk(workspacePath).filter(_.ext == "scala")){
+ os.write.append(scalaFile, "\n}")
}
assert(!eval("akka.test"))
}
diff --git a/integration/test/src/mill/integration/DocAnnotationsTests.scala b/integration/test/src/mill/integration/DocAnnotationsTests.scala
index 75579689..4d7ef11b 100644
--- a/integration/test/src/mill/integration/DocAnnotationsTests.scala
+++ b/integration/test/src/mill/integration/DocAnnotationsTests.scala
@@ -1,12 +1,11 @@
package mill.integration
-import ammonite.ops.{Path, pwd}
import mill.util.ScriptTestSuite
import utest._
class DocAnnotationsTests(fork: Boolean) extends ScriptTestSuite(fork) {
def workspaceSlug: String = "docannotations"
- def scriptSourcePath: Path = pwd / 'integration / 'test / 'resources / workspaceSlug
+ def scriptSourcePath: os.Path = os.pwd / 'integration / 'test / 'resources / workspaceSlug
val tests = Tests{
initWorkspace()
'test - {
diff --git a/integration/test/src/mill/integration/IntegrationTestSuite.scala b/integration/test/src/mill/integration/IntegrationTestSuite.scala
index 721557c0..ca041eea 100644
--- a/integration/test/src/mill/integration/IntegrationTestSuite.scala
+++ b/integration/test/src/mill/integration/IntegrationTestSuite.scala
@@ -1,29 +1,28 @@
package mill.integration
-import ammonite.ops._
import mill.util.ScriptTestSuite
import utest._
abstract class IntegrationTestSuite(repoKey: String, val workspaceSlug: String, fork: Boolean)
extends ScriptTestSuite(fork){
- val buildFilePath = pwd / 'integration / 'test / 'resources / workspaceSlug
+ val buildFilePath = os.pwd / 'integration / 'test / 'resources / workspaceSlug
def scriptSourcePath = {
// The unzipped git repo snapshots we get from github come with a
// wrapper-folder inside the zip file, so copy the wrapper folder to the
// destination instead of the folder containing the wrapper.
val path = sys.props(repoKey)
- val Seq(wrapper) = ls(Path(path))
+ val Seq(wrapper) = os.list(os.Path(path))
wrapper
}
- def buildFiles: Seq[Path] = ls.rec(buildFilePath)
+ def buildFiles: Seq[os.Path] = os.walk(buildFilePath)
override def initWorkspace() = {
super.initWorkspace()
buildFiles.foreach { file =>
- cp.over(file, workspacePath / file.name)
+ os.copy.over(file, workspacePath / file.last)
}
- assert(!ls.rec(workspacePath).exists(_.ext == "class"))
+ assert(!os.walk(workspacePath).exists(_.ext == "class"))
}
}
diff --git a/integration/test/src/mill/integration/JawnTests.scala b/integration/test/src/mill/integration/JawnTests.scala
index da584e01..eafd1009 100644
--- a/integration/test/src/mill/integration/JawnTests.scala
+++ b/integration/test/src/mill/integration/JawnTests.scala
@@ -1,6 +1,5 @@
package mill.integration
-import ammonite.ops._
import utest._
class JawnTests(fork: Boolean)
@@ -13,12 +12,12 @@ class JawnTests(fork: Boolean)
assert(
firstCompile,
- ls.rec(workspacePath).exists(_.last == "AsyncParser.class"),
- ls.rec(workspacePath).exists(_.last == "CharBuilderSpec.class")
+ os.walk(workspacePath).exists(_.last == "AsyncParser.class"),
+ os.walk(workspacePath).exists(_.last == "CharBuilderSpec.class")
)
- for(scalaFile <- ls.rec(workspacePath).filter(_.ext == "scala")){
- write.append(scalaFile, "\n}")
+ for(scalaFile <- os.walk(workspacePath).filter(_.ext == "scala")){
+ os.write.append(scalaFile, "\n}")
}
val brokenCompile = eval(s"jawn[$scalaVersion].parser.test")
diff --git a/integration/test/src/mill/integration/PlayJsonTests.scala b/integration/test/src/mill/integration/PlayJsonTests.scala
index c78a256e..262dcb36 100644
--- a/integration/test/src/mill/integration/PlayJsonTests.scala
+++ b/integration/test/src/mill/integration/PlayJsonTests.scala
@@ -1,12 +1,12 @@
package mill.integration
-import ammonite.ops._
+
import utest._
class PlayJsonTests(fork: Boolean) extends IntegrationTestSuite("MILL_PLAY_JSON_REPO", "play-json", fork) {
- override def buildFiles: Seq[Path] = {
- ls(buildFilePath).filter(_.ext == "sc")
+ override def buildFiles: Seq[os.Path] = {
+ os.list(buildFilePath).filter(_.ext == "sc")
}
val tests = Tests{
diff --git a/integration/test/src/mill/integration/UpickleTests.scala b/integration/test/src/mill/integration/UpickleTests.scala
index 1b83c60f..133188d3 100644
--- a/integration/test/src/mill/integration/UpickleTests.scala
+++ b/integration/test/src/mill/integration/UpickleTests.scala
@@ -1,6 +1,5 @@
package mill.integration
-import ammonite.ops._
import utest._
class UpickleTests(fork: Boolean) extends IntegrationTestSuite("MILL_UPICKLE_REPO", "upickle", fork) {
diff --git a/main/core/src/mill/define/BaseModule.scala b/main/core/src/mill/define/BaseModule.scala
index 03bdeccc..cd79f73e 100644
--- a/main/core/src/mill/define/BaseModule.scala
+++ b/main/core/src/mill/define/BaseModule.scala
@@ -1,12 +1,11 @@
package mill.define
-import ammonite.ops.Path
object BaseModule{
case class Implicit(value: BaseModule)
}
-abstract class BaseModule(millSourcePath0: Path,
+abstract class BaseModule(millSourcePath0: os.Path,
external0: Boolean = false,
foreign0 : Boolean = false)
(implicit millModuleEnclosing0: sourcecode.Enclosing,
diff --git a/main/core/src/mill/define/Ctx.scala b/main/core/src/mill/define/Ctx.scala
index ba4fae9e..c21e53b4 100644
--- a/main/core/src/mill/define/Ctx.scala
+++ b/main/core/src/mill/define/Ctx.scala
@@ -1,8 +1,6 @@
package mill.define
-import ammonite.ops.Path
-
import scala.annotation.implicitNotFound
sealed trait Segment{
@@ -18,7 +16,7 @@ object Segment{
case class Cross(value: Seq[Any]) extends Segment
}
-case class BasePath(value: Path)
+case class BasePath(value: os.Path)
/**
@@ -64,7 +62,7 @@ object Segments {
case class Ctx(enclosing: String,
lineNum: Int,
segment: Segment,
- millSourcePath: Path,
+ millSourcePath: os.Path,
segments: Segments,
overrides: Int,
external: Boolean,
diff --git a/main/core/src/mill/define/Module.scala b/main/core/src/mill/define/Module.scala
index f72ec8ca..a8fc5be7 100644
--- a/main/core/src/mill/define/Module.scala
+++ b/main/core/src/mill/define/Module.scala
@@ -2,7 +2,6 @@ package mill.define
import java.lang.reflect.Modifier
-import ammonite.ops.Path
import mill.util.ParseArgs
import scala.language.experimental.macros
@@ -27,7 +26,7 @@ class Module(implicit outerCtx0: mill.define.Ctx)
lazy val millModuleDirectChildren = millInternal.reflectNestedObjects[Module].toSeq
def millOuterCtx = outerCtx0
- def millSourcePath: Path = millOuterCtx.millSourcePath / millOuterCtx.segment.pathSegments
+ def millSourcePath: os.Path = millOuterCtx.millSourcePath / millOuterCtx.segment.pathSegments
implicit def millModuleExternal: Ctx.External = Ctx.External(millOuterCtx.external)
implicit def millModuleShared: Ctx.Foreign = Ctx.Foreign(millOuterCtx.foreign)
implicit def millModuleBasePath: BasePath = BasePath(millSourcePath)
diff --git a/main/core/src/mill/define/Task.scala b/main/core/src/mill/define/Task.scala
index 64e868f8..07576724 100644
--- a/main/core/src/mill/define/Task.scala
+++ b/main/core/src/mill/define/Task.scala
@@ -109,11 +109,11 @@ object Target extends TargetGenerated with Applicative.Applyer[Task, Task, Resul
)
}
- def sources(values: Result[ammonite.ops.Path]*)
+ def sources(values: Result[os.Path]*)
(implicit ctx: mill.define.Ctx): Sources = macro sourcesImpl1
def sourcesImpl1(c: Context)
- (values: c.Expr[Result[ammonite.ops.Path]]*)
+ (values: c.Expr[Result[os.Path]]*)
(ctx: c.Expr[mill.define.Ctx]): c.Expr[Sources] = {
import c.universe._
val wrapped =
diff --git a/main/core/src/mill/eval/Evaluator.scala b/main/core/src/mill/eval/Evaluator.scala
index 2ffc469b..7cf55fdb 100644
--- a/main/core/src/mill/eval/Evaluator.scala
+++ b/main/core/src/mill/eval/Evaluator.scala
@@ -5,7 +5,6 @@ import java.net.URLClassLoader
import scala.collection.JavaConverters._
import mill.util.Router.EntryPoint
-import ammonite.ops._
import ammonite.runtime.SpecialClassLoader
import mill.define.{Ctx => _, _}
import mill.eval.Result.OuterStack
@@ -29,17 +28,17 @@ case class Labelled[T](task: NamedTask[T],
}
}
-case class Evaluator(home: Path,
- outPath: Path,
- externalOutPath: Path,
+case class Evaluator(home: os.Path,
+ outPath: os.Path,
+ externalOutPath: os.Path,
rootModule: mill.define.BaseModule,
log: Logger,
- classLoaderSig: Seq[(Either[String, Path], Long)] = Evaluator.classLoaderSig,
+ classLoaderSig: Seq[(Either[String, os.Path], Long)] = Evaluator.classLoaderSig,
workerCache: mutable.Map[Segments, (Int, Any)] = mutable.Map.empty,
env : Map[String, String] = Evaluator.defaultEnv){
val classLoaderSignHash = classLoaderSig.hashCode()
def evaluate(goals: Agg[Task[_]]): Evaluator.Results = {
- mkdir(outPath)
+ os.makeDir.all(outPath)
val (sortedGroups, transitive) = Evaluator.plan(rootModule, goals)
@@ -76,7 +75,7 @@ case class Evaluator(home: Path,
vs.items.flatMap(results.get).collect{case f: Result.Failing[_] => f.map(_._1)}
)
}
- write.over(
+ os.write.over(
outPath / "mill-profile.json",
upickle.default.write(
timings .map{case (k, v, b) =>
@@ -133,7 +132,7 @@ case class Evaluator(home: Path,
destSegments(labelledNamedTask)
)
- if (!exists(paths.out)) mkdir(paths.out)
+ if (!os.exists(paths.out)) os.makeDir.all(paths.out)
val cached = for{
cached <-
try Some(upickle.default.read[Evaluator.Cached](paths.meta.toIO))
@@ -158,14 +157,13 @@ case class Evaluator(home: Path,
(newResults, Nil, true)
case _ =>
-
val Seq(first, rest @_*) = labelledNamedTask.segments.value
val msgParts = Seq(first.asInstanceOf[Segment.Label].value) ++ rest.map{
case Segment.Label(s) => "." + s
case Segment.Cross(s) => "[" + s.mkString(",") + "]"
}
- if (labelledNamedTask.task.flushDest) rm(paths.dest)
+ if (labelledNamedTask.task.flushDest) os.remove.all(paths.dest)
val (newResults, newEvaluated) = evaluateGroup(
group,
@@ -188,7 +186,7 @@ case class Evaluator(home: Path,
// a following run won't look at the cached metadata file and
// assume it's associated with the possibly-borked state of the
// destPath after an evaluation failure.
- rm(paths.meta)
+ os.remove.all(paths.meta)
}
(newResults, newEvaluated, false)
@@ -218,7 +216,7 @@ case class Evaluator(home: Path,
def handleTaskResult(v: Any,
hashCode: Int,
- metaPath: Path,
+ metaPath: os.Path,
inputsHash: Int,
labelledNamedTask: Labelled[_]) = {
labelledNamedTask.task.asWorker match{
@@ -230,7 +228,7 @@ case class Evaluator(home: Path,
.map(w => upickle.default.writeJs(v)(w) -> v)
for((json, v) <- terminalResult){
- write.over(
+ os.write.over(
metaPath,
upickle.default.write(
Evaluator.Cached(json, hashCode, inputsHash),
@@ -270,7 +268,13 @@ case class Evaluator(home: Path,
for (task <- nonEvaluatedTargets) {
newEvaluated.append(task)
val targetInputValues = task.inputs
- .map(x => newResults.getOrElse(x, results(x)))
+ .map{x =>
+ val res = newResults.getOrElse(x, results(x))
+ if (!res.isInstanceOf[Result.Success[_]]){
+ println("FAILURE " + x)
+ }
+ res
+ }
.collect{ case Result.Success((v, hashCode)) => v }
val res =
@@ -291,7 +295,7 @@ case class Evaluator(home: Path,
paths match{
case Some(dest) =>
- if (usedDest.isEmpty) mkdir(dest.dest)
+ if (usedDest.isEmpty) os.makeDir.all(dest.dest)
usedDest = Some((task, new Exception().getStackTrace))
dest.dest
case None =>
@@ -340,7 +344,7 @@ case class Evaluator(home: Path,
(newResults, newEvaluated)
}
- def resolveLogger(logPath: Option[Path]): Logger = logPath match{
+ def resolveLogger(logPath: Option[os.Path]): Logger = logPath match{
case None => log
case Some(path) => MultiLogger(log.colored, log, FileLogger(log.colored, path, debugEnabled = true))
}
@@ -355,9 +359,9 @@ object Evaluator{
implicit val rw: upickle.default.ReadWriter[Cached] = upickle.default.macroRW
}
case class State(rootModule: mill.define.BaseModule,
- classLoaderSig: Seq[(Either[String, Path], Long)],
+ classLoaderSig: Seq[(Either[String, os.Path], Long)],
workerCache: mutable.Map[Segments, (Int, Any)],
- watched: Seq[(Path, Long)])
+ watched: Seq[(os.Path, Long)])
// This needs to be a ThreadLocal because we need to pass it into the body of
// the TargetScopt#read call, which does not accept additional parameters.
// Until we migrate our CLI parsing off of Scopt (so we can pass the BaseModule
@@ -366,15 +370,15 @@ object Evaluator{
val defaultEnv: Map[String, String] = System.getenv().asScala.toMap
- case class Paths(out: Path,
- dest: Path,
- meta: Path,
- log: Path)
+ case class Paths(out: os.Path,
+ dest: os.Path,
+ meta: os.Path,
+ log: os.Path)
def makeSegmentStrings(segments: Segments) = segments.value.flatMap{
case Segment.Label(s) => Seq(s)
case Segment.Cross(values) => values.map(_.toString)
}
- def resolveDestPaths(workspacePath: Path, segments: Segments): Paths = {
+ def resolveDestPaths(workspacePath: os.Path, segments: Segments): Paths = {
val segmentStrings = makeSegmentStrings(segments)
val targetPath = workspacePath / segmentStrings
Paths(targetPath, targetPath / 'dest, targetPath / "meta.json", targetPath / 'log)
diff --git a/main/core/src/mill/eval/PathRef.scala b/main/core/src/mill/eval/PathRef.scala
index 4983f040..92ef8d24 100644
--- a/main/core/src/mill/eval/PathRef.scala
+++ b/main/core/src/mill/eval/PathRef.scala
@@ -7,54 +7,41 @@ import java.nio.{file => jnio}
import java.security.{DigestOutputStream, MessageDigest}
import upickle.default.{ReadWriter => RW}
-import ammonite.ops.Path
import mill.util.{DummyOutputStream, IO, JsonFormatters}
/**
- * A wrapper around `ammonite.ops.Path` that calculates it's hashcode based
+ * A wrapper around `os.Path` that calculates it's hashcode based
* on the contents of the filesystem underneath it. Used to ensure filesystem
* changes can bust caches which are keyed off hashcodes.
*/
-case class PathRef(path: ammonite.ops.Path, quick: Boolean, sig: Int){
+case class PathRef(path: os.Path, quick: Boolean, sig: Int){
override def hashCode() = sig
}
object PathRef{
- def apply(path: ammonite.ops.Path, quick: Boolean = false) = {
+ def apply(path: os.Path, quick: Boolean = false) = {
val sig = {
val digest = MessageDigest.getInstance("MD5")
val digestOut = new DigestOutputStream(DummyOutputStream, digest)
- jnio.Files.walkFileTree(
- path.toNIO,
- java.util.EnumSet.of(jnio.FileVisitOption.FOLLOW_LINKS),
- Integer.MAX_VALUE,
- new FileVisitor[jnio.Path] {
- def preVisitDirectory(dir: jnio.Path, attrs: BasicFileAttributes) = {
- digest.update(dir.toAbsolutePath.toString.getBytes)
- FileVisitResult.CONTINUE
- }
-
- def visitFile(file: jnio.Path, attrs: BasicFileAttributes) = {
- digest.update(file.toAbsolutePath.toString.getBytes)
+ if (os.exists(path)){
+ for((path, attrs) <- os.walk.attrs(path, includeTarget = true, followLinks = true)){
+ digest.update(path.toString.getBytes)
+ if (!attrs.isDir) {
if (quick){
- val value = (path.mtime.toMillis, path.size).hashCode()
+ val value = (attrs.mtime, attrs.size).hashCode()
digest.update((value >>> 24).toByte)
digest.update((value >>> 16).toByte)
digest.update((value >>> 8).toByte)
digest.update(value.toByte)
- } else if (jnio.Files.isReadable(file)) {
- val is = jnio.Files.newInputStream(file)
+ } else if (jnio.Files.isReadable(path.toNIO)) {
+ val is = os.read.inputStream(path)
IO.stream(is, digestOut)
is.close()
}
- FileVisitResult.CONTINUE
}
-
- def visitFileFailed(file: jnio.Path, exc: IOException) = FileVisitResult.CONTINUE
- def postVisitDirectory(dir: jnio.Path, exc: IOException) = FileVisitResult.CONTINUE
}
- )
+ }
java.util.Arrays.hashCode(digest.digest())
@@ -71,7 +58,7 @@ object PathRef{
s => {
val Array(prefix, hex, path) = s.split(":", 3)
PathRef(
- Path(path),
+ os.Path(path),
prefix match{ case "qref" => true case "ref" => false},
// Parsing to a long and casting to an int is the only way to make
// round-trip handling of negative numbers work =(
diff --git a/main/core/src/mill/util/ClassLoader.scala b/main/core/src/mill/util/ClassLoader.scala
index ebe8e50b..07ab1ca9 100644
--- a/main/core/src/mill/util/ClassLoader.scala
+++ b/main/core/src/mill/util/ClassLoader.scala
@@ -2,7 +2,7 @@ package mill.util
import java.net.{URL, URLClassLoader}
-import ammonite.ops._
+
import io.github.retronym.java9rtexport.Export
import scala.util.Try
diff --git a/main/core/src/mill/util/Ctx.scala b/main/core/src/mill/util/Ctx.scala
index 6c8b2afb..bbc243b7 100644
--- a/main/core/src/mill/util/Ctx.scala
+++ b/main/core/src/mill/util/Ctx.scala
@@ -1,6 +1,5 @@
package mill.util
-import ammonite.ops.Path
import mill.define.Applicative.ImplicitStub
import scala.annotation.compileTimeOnly
@@ -12,16 +11,16 @@ object Ctx{
implicit def taskCtx: Ctx = ???
object Dest {
- implicit def pathToCtx(path: Path): Dest = new Dest { def dest = path }
+ implicit def pathToCtx(path: os.Path): Dest = new Dest { def dest = path }
}
trait Dest{
- def dest: Path
+ def dest: os.Path
}
trait Log{
def log: Logger
}
trait Home{
- def home: Path
+ def home: os.Path
}
trait Env{
def env: Map[String, String]
@@ -37,9 +36,9 @@ object Ctx{
}
class Ctx(val args: IndexedSeq[_],
- dest0: () => Path,
+ dest0: () => os.Path,
val log: Logger,
- val home: Path,
+ val home: os.Path,
val env : Map[String, String])
extends Ctx.Dest
with Ctx.Log
diff --git a/main/core/src/mill/util/JsonFormatters.scala b/main/core/src/mill/util/JsonFormatters.scala
index 2728d94d..e2c3073f 100644
--- a/main/core/src/mill/util/JsonFormatters.scala
+++ b/main/core/src/mill/util/JsonFormatters.scala
@@ -1,15 +1,14 @@
package mill.util
-import ammonite.ops.{Bytes, Path}
import upickle.Js
import upickle.default.{ReadWriter => RW}
import scala.util.matching.Regex
object JsonFormatters extends JsonFormatters
trait JsonFormatters {
- implicit val pathReadWrite: RW[ammonite.ops.Path] = upickle.default.readwriter[String]
- .bimap[ammonite.ops.Path](
+ implicit val pathReadWrite: RW[os.Path] = upickle.default.readwriter[String]
+ .bimap[os.Path](
_.toString,
- Path(_)
+ os.Path(_)
)
implicit val regexReadWrite: RW[Regex] = upickle.default.readwriter[String]
@@ -18,14 +17,14 @@ trait JsonFormatters {
_.r
)
- implicit val bytesReadWrite: RW[Bytes] = upickle.default.readwriter[String]
+ implicit val bytesReadWrite: RW[os.Bytes] = upickle.default.readwriter[String]
.bimap(
- o => javax.xml.bind.DatatypeConverter.printBase64Binary(o.array),
- str => new Bytes(javax.xml.bind.DatatypeConverter.parseBase64Binary(str))
+ o => java.util.Base64.getEncoder.encodeToString(o.array),
+ str => new os.Bytes(java.util.Base64.getDecoder.decode(str))
)
- implicit lazy val crFormat: RW[ammonite.ops.CommandResult] = upickle.default.macroRW
+ implicit lazy val crFormat: RW[os.CommandResult] = upickle.default.macroRW
implicit lazy val modFormat: RW[coursier.Module] = upickle.default.macroRW
implicit lazy val depFormat: RW[coursier.Dependency]= upickle.default.macroRW
diff --git a/main/core/src/mill/util/Logger.scala b/main/core/src/mill/util/Logger.scala
index 1db66039..4857953d 100644
--- a/main/core/src/mill/util/Logger.scala
+++ b/main/core/src/mill/util/Logger.scala
@@ -2,7 +2,6 @@ package mill.util
import java.io._
-import ammonite.ops.{Path, rm}
import ammonite.util.Colors
/**
@@ -142,17 +141,17 @@ case class PrintLogger(
}
}
-case class FileLogger(colored: Boolean, file: Path, debugEnabled: Boolean) extends Logger {
+case class FileLogger(colored: Boolean, file: os.Path, debugEnabled: Boolean) extends Logger {
private[this] var outputStreamUsed: Boolean = false
lazy val outputStream = {
- if (!outputStreamUsed) rm(file)
+ if (!outputStreamUsed) os.remove.all(file)
outputStreamUsed = true
new PrintStream(new FileOutputStream(file.toIO.getAbsolutePath))
}
lazy val errorStream = {
- if (!outputStreamUsed) rm(file)
+ if (!outputStreamUsed) os.remove.all(file)
outputStreamUsed = true
new PrintStream(new FileOutputStream(file.toIO.getAbsolutePath))
}
diff --git a/main/core/src/mill/util/Scripts.scala b/main/core/src/mill/util/Scripts.scala
index 1815b6de..65eb6b2b 100644
--- a/main/core/src/mill/util/Scripts.scala
+++ b/main/core/src/mill/util/Scripts.scala
@@ -2,7 +2,7 @@ package mill.util
import java.nio.file.NoSuchFileException
-import ammonite.ops._
+
import ammonite.runtime.Evaluator.AmmoniteExit
import ammonite.util.Name.backtickWrap
import ammonite.util.Util.CodeSource
@@ -31,15 +31,15 @@ object Scripts {
scriptArgs
}
- def runScript(wd: Path,
- path: Path,
+ def runScript(wd: os.Path,
+ path: os.Path,
interp: ammonite.interp.Interpreter,
scriptArgs: Seq[(String, Option[String])] = Nil) = {
interp.watch(path)
val (pkg, wrapper) = Util.pathToPackageWrapper(Seq(), path relativeTo wd)
for{
- scriptTxt <- try Res.Success(Util.normalizeNewlines(read(path))) catch{
+ scriptTxt <- try Res.Success(Util.normalizeNewlines(os.read(path))) catch{
case e: NoSuchFileException => Res.Failure("Script file not found: " + path)
}
@@ -169,7 +169,7 @@ object Scripts {
for((lhs, rhs) <- args)
yield {
val lhsPadded = lhs.padTo(leftColWidth, ' ')
- val rhsPadded = rhs.lines.mkString(Util.newLine)
+ val rhsPadded = rhs.linesIterator.mkString(Util.newLine)
s"$leftIndentStr $lhsPadded $rhsPadded"
}
val mainDocSuffix = main.doc match{
@@ -273,7 +273,7 @@ object Scripts {
}
def softWrap(s: String, leftOffset: Int, maxWidth: Int) = {
- val oneLine = s.lines.mkString(" ").split(' ')
+ val oneLine = s.linesIterator.mkString(" ").split(' ')
lazy val indent = " " * leftOffset
@@ -325,6 +325,6 @@ object Scripts {
/**
* Additional [[scopt.Read]] instance to teach it how to read Ammonite paths
*/
- implicit def pathScoptRead: scopt.Read[Path] = scopt.Read.stringRead.map(Path(_, pwd))
+ implicit def pathScoptRead: scopt.Read[os.Path] = scopt.Read.stringRead.map(os.Path(_, os.pwd))
}
diff --git a/main/graphviz/src/mill/main/graphviz/GraphvizTools.scala b/main/graphviz/src/mill/main/graphviz/GraphvizTools.scala
index 4e8c59ce..9812c81f 100644
--- a/main/graphviz/src/mill/main/graphviz/GraphvizTools.scala
+++ b/main/graphviz/src/mill/main/graphviz/GraphvizTools.scala
@@ -1,10 +1,9 @@
package mill.main.graphviz
-import ammonite.ops.Path
import guru.nidi.graphviz.attribute.Style
import mill.define.{Graph, NamedTask}
import org.jgrapht.graph.{DefaultEdge, SimpleDirectedGraph}
object GraphvizTools{
- def apply(targets: Seq[NamedTask[Any]], rs: Seq[NamedTask[Any]], dest: Path) = {
+ def apply(targets: Seq[NamedTask[Any]], rs: Seq[NamedTask[Any]], dest: os.Path) = {
val transitive = Graph.transitiveTargets(rs.distinct)
val topoSorted = Graph.topoSorted(transitive)
val goalSet = rs.toSet
diff --git a/main/src/mill/MillMain.scala b/main/src/mill/MillMain.scala
index 1598d5f3..d36b6f42 100644
--- a/main/src/mill/MillMain.scala
+++ b/main/src/mill/MillMain.scala
@@ -4,7 +4,6 @@ import java.io.{InputStream, PrintStream}
import scala.collection.JavaConverters._
import ammonite.main.Cli._
-import ammonite.ops._
import io.github.retronym.java9rtexport.Export
import mill.eval.Evaluator
import mill.util.DummyInputStream
@@ -110,7 +109,7 @@ object MillMain {
predefCode =
s"""import $$file.build, build._
|implicit val replApplyHandler = mill.main.ReplApplyHandler(
- | ammonite.ops.Path(${pprint.apply(cliConfig.home.toIO.getCanonicalPath.replaceAllLiterally("$", "$$")).plainText}),
+ | os.Path(${pprint.apply(cliConfig.home.toIO.getCanonicalPath.replaceAllLiterally("$", "$$")).plainText}),
| $disableTicker,
| interp.colors(),
| repl.pprinter(),
@@ -137,7 +136,7 @@ object MillMain {
if (mill.main.client.Util.isJava9OrAbove) {
val rt = cliConfig.home / Export.rtJarName
- if (!exists(rt)) {
+ if (!os.exists(rt)) {
runner.printInfo(s"Preparing Java ${System.getProperty("java.version")} runtime; this may take a minute or two ...")
Export.rtTo(rt.toIO, false)
}
@@ -147,7 +146,7 @@ object MillMain {
runner.printInfo("Loading...")
(runner.watchLoop(isRepl = true, printing = false, _.run()), runner.stateCache)
} else {
- (runner.runScript(pwd / "build.sc", leftoverArgs), runner.stateCache)
+ (runner.runScript(os.pwd / "build.sc", leftoverArgs), runner.stateCache)
}
}
diff --git a/main/src/mill/main/MainModule.scala b/main/src/mill/main/MainModule.scala
index 929ad3dc..a740a2e6 100644
--- a/main/src/mill/main/MainModule.scala
+++ b/main/src/mill/main/MainModule.scala
@@ -2,7 +2,6 @@ package mill.main
import java.util.concurrent.LinkedBlockingQueue
-import ammonite.ops.Path
import mill.T
import mill.define.{NamedTask, Task}
import mill.eval.{Evaluator, PathRef, Result}
@@ -200,7 +199,7 @@ trait MainModule extends mill.Module{
val KeepPattern = "(mill-.+)".r.anchored
- def keepPath(path: Path) = path.segments.lastOption match {
+ def keepPath(path: os.Path) = path.segments.toSeq.lastOption match {
case Some(KeepPattern(_)) => true
case _ => false
}
@@ -220,7 +219,7 @@ trait MainModule extends mill.Module{
case Left(err) =>
Result.Failure(err)
case Right(paths) =>
- paths.foreach(ammonite.ops.rm)
+ paths.foreach(os.remove.all)
Result.Success(())
}
}
@@ -245,7 +244,7 @@ trait MainModule extends mill.Module{
}
}
- private type VizWorker = (LinkedBlockingQueue[(scala.Seq[_], scala.Seq[_], Path)],
+ private type VizWorker = (LinkedBlockingQueue[(scala.Seq[_], scala.Seq[_], os.Path)],
LinkedBlockingQueue[Result[scala.Seq[PathRef]]])
private def visualize0(evaluator: Evaluator, targets: Seq[String], ctx: Ctx, vizWorker: VizWorker,
diff --git a/main/src/mill/main/MainRunner.scala b/main/src/mill/main/MainRunner.scala
index 4f31a724..e50ed370 100644
--- a/main/src/mill/main/MainRunner.scala
+++ b/main/src/mill/main/MainRunner.scala
@@ -3,7 +3,6 @@ import java.io.{InputStream, PrintStream}
import ammonite.Main
import ammonite.interp.{Interpreter, Preprocessor}
-import ammonite.ops.Path
import ammonite.util.Util.CodeSource
import ammonite.util._
import mill.eval.{Evaluator, PathRef}
@@ -33,7 +32,7 @@ class MainRunner(val config: ammonite.main.Cli.Config,
var stateCache = stateCache0
- override def watchAndWait(watched: Seq[(Path, Long)]) = {
+ override def watchAndWait(watched: Seq[(os.Path, Long)]) = {
printInfo(s"Watching for changes to ${watched.length} files... (Ctrl-C to exit)")
def statAll() = watched.forall{ case (file, lastMTime) =>
Interpreter.pathSignature(file) == lastMTime
@@ -50,7 +49,7 @@ class MainRunner(val config: ammonite.main.Cli.Config,
*/
@tailrec final def watchLoop2[T](isRepl: Boolean,
printing: Boolean,
- run: Main => (Res[T], () => Seq[(Path, Long)])): Boolean = {
+ run: Main => (Res[T], () => Seq[(os.Path, Long)])): Boolean = {
val (result, watched) = run(initMain(isRepl))
val success = handleWatchRes(result, printing)
@@ -62,7 +61,7 @@ class MainRunner(val config: ammonite.main.Cli.Config,
}
- override def runScript(scriptPath: Path, scriptArgs: List[String]) =
+ override def runScript(scriptPath: os.Path, scriptArgs: List[String]) =
watchLoop2(
isRepl = false,
printing = true,
@@ -146,7 +145,7 @@ class MainRunner(val config: ammonite.main.Cli.Config,
|$imports
|import mill._
|object $wrapName
- |extends mill.define.BaseModule(ammonite.ops.Path($literalPath), foreign0 = $external)(
+ |extends mill.define.BaseModule(os.Path($literalPath), foreign0 = $external)(
| implicitly, implicitly, implicitly, implicitly, mill.define.Caller(())
|)
|with $wrapName{
diff --git a/main/src/mill/main/ReplApplyHandler.scala b/main/src/mill/main/ReplApplyHandler.scala
index af69c761..a8e467d4 100644
--- a/main/src/mill/main/ReplApplyHandler.scala
+++ b/main/src/mill/main/ReplApplyHandler.scala
@@ -1,7 +1,6 @@
package mill.main
-import ammonite.ops.Path
import mill.define.Applicative.ApplyHandler
import mill.define.Segment.Label
import mill.define._
@@ -11,7 +10,7 @@ import mill.util.Strict.Agg
import scala.collection.mutable
object ReplApplyHandler{
- def apply[T](home: Path,
+ def apply[T](home: os.Path,
disableTicker: Boolean,
colors: ammonite.util.Colors,
pprinter0: pprint.PPrinter,
diff --git a/main/src/mill/main/RunScript.scala b/main/src/mill/main/RunScript.scala
index 1c8503fe..820b1341 100644
--- a/main/src/mill/main/RunScript.scala
+++ b/main/src/mill/main/RunScript.scala
@@ -3,7 +3,6 @@ package mill.main
import java.nio.file.NoSuchFileException
import ammonite.interp.Interpreter
-import ammonite.ops.{Path, read}
import ammonite.runtime.SpecialClassLoader
import ammonite.util.Util.CodeSource
import ammonite.util.{Name, Res, Util}
@@ -23,15 +22,15 @@ import scala.reflect.ClassTag
* subsystem
*/
object RunScript{
- def runScript(home: Path,
- wd: Path,
- path: Path,
- instantiateInterpreter: => Either[(Res.Failing, Seq[(Path, Long)]), ammonite.interp.Interpreter],
+ def runScript(home: os.Path,
+ wd: os.Path,
+ path: os.Path,
+ instantiateInterpreter: => Either[(Res.Failing, Seq[(os.Path, Long)]), ammonite.interp.Interpreter],
scriptArgs: Seq[String],
stateCache: Option[Evaluator.State],
log: Logger,
env : Map[String, String])
- : (Res[(Evaluator, Seq[PathRef], Either[String, Seq[Js.Value]])], Seq[(Path, Long)]) = {
+ : (Res[(Evaluator, Seq[PathRef], Either[String, Seq[Js.Value]])], Seq[(os.Path, Long)]) = {
val (evalState, interpWatched) = stateCache match{
case Some(s) if watchedSigUnchanged(s.watched) => Res.Success(s) -> s.watched
@@ -66,12 +65,12 @@ object RunScript{
(evaluated, interpWatched)
}
- def watchedSigUnchanged(sig: Seq[(Path, Long)]) = {
+ def watchedSigUnchanged(sig: Seq[(os.Path, Long)]) = {
sig.forall{case (p, l) => Interpreter.pathSignature(p) == l}
}
- def evaluateRootModule(wd: Path,
- path: Path,
+ def evaluateRootModule(wd: os.Path,
+ path: os.Path,
interp: ammonite.interp.Interpreter,
log: Logger
): Res[mill.define.BaseModule] = {
@@ -80,7 +79,7 @@ object RunScript{
for {
scriptTxt <-
- try Res.Success(Util.normalizeNewlines(read(path)))
+ try Res.Success(Util.normalizeNewlines(os.read(path)))
catch { case _: NoSuchFileException =>
log.info("No build file found, you should create build.sc to do something useful")
Res.Success("")
diff --git a/main/src/mill/main/VisualizeModule.scala b/main/src/mill/main/VisualizeModule.scala
index ea4d46c6..71b9fc22 100644
--- a/main/src/mill/main/VisualizeModule.scala
+++ b/main/src/mill/main/VisualizeModule.scala
@@ -2,7 +2,6 @@ package mill.main
import java.util.concurrent.LinkedBlockingQueue
-import ammonite.ops.Path
import coursier.Cache
import coursier.core.Repository
import coursier.maven.MavenRepository
@@ -35,7 +34,7 @@ trait VisualizeModule extends mill.define.TaskModule{
* can communicate via in/out queues.
*/
def worker = T.worker{
- val in = new LinkedBlockingQueue[(Seq[_], Seq[_], Path)]()
+ val in = new LinkedBlockingQueue[(Seq[_], Seq[_], os.Path)]()
val out = new LinkedBlockingQueue[Result[Seq[PathRef]]]()
val cl = mill.util.ClassLoader.create(
@@ -47,7 +46,7 @@ trait VisualizeModule extends mill.define.TaskModule{
val res = Result.create{
val (targets, tasks, dest) = in.take()
cl.loadClass("mill.main.graphviz.GraphvizTools")
- .getMethod("apply", classOf[Seq[_]], classOf[Seq[_]], classOf[Path])
+ .getMethod("apply", classOf[Seq[_]], classOf[Seq[_]], classOf[os.Path])
.invoke(null, targets, tasks, dest)
.asInstanceOf[Seq[PathRef]]
}
diff --git a/main/src/mill/modules/Assembly.scala b/main/src/mill/modules/Assembly.scala
index b7b91248..141bc226 100644
--- a/main/src/mill/modules/Assembly.scala
+++ b/main/src/mill/modules/Assembly.scala
@@ -4,7 +4,6 @@ import java.io.InputStream
import java.util.jar.JarFile
import java.util.regex.Pattern
-import ammonite.ops._
import geny.Generator
import mill.Agg
@@ -37,7 +36,7 @@ object Assembly {
case class ExcludePattern(pattern: Pattern) extends Rule
}
- def groupAssemblyEntries(inputPaths: Agg[Path], assemblyRules: Seq[Assembly.Rule]): Map[String, GroupedEntry] = {
+ def groupAssemblyEntries(inputPaths: Agg[os.Path], assemblyRules: Seq[Assembly.Rule]): Map[String, GroupedEntry] = {
val rulesMap = assemblyRules.collect {
case r@Rule.Append(path) => path -> r
case r@Rule.Exclude(path) => path -> r
@@ -76,12 +75,12 @@ object Assembly {
}
}
- private def classpathIterator(inputPaths: Agg[Path]): Generator[AssemblyEntry] = {
+ private def classpathIterator(inputPaths: Agg[os.Path]): Generator[AssemblyEntry] = {
Generator.from(inputPaths)
- .filter(exists)
+ .filter(os.exists)
.flatMap {
p =>
- if (p.isFile) {
+ if (os.isFile(p)) {
val jf = new JarFile(p.toIO)
Generator.from(
for(entry <- jf.entries().asScala if !entry.isDirectory)
@@ -89,8 +88,8 @@ object Assembly {
)
}
else {
- ls.rec.iter(p)
- .filter(_.isFile)
+ os.walk.stream(p)
+ .filter(os.isFile)
.map(sub => PathEntry(sub.relativeTo(p).toString, sub))
}
}
@@ -118,8 +117,8 @@ private[this] sealed trait AssemblyEntry {
def inputStream: InputStream
}
-private[this] case class PathEntry(mapping: String, path: Path) extends AssemblyEntry {
- def inputStream: InputStream = read.getInputStream(path)
+private[this] case class PathEntry(mapping: String, path: os.Path) extends AssemblyEntry {
+ def inputStream: InputStream = os.read.inputStream(path)
}
private[this] case class JarFileEntry(mapping: String, getIs: () => InputStream) extends AssemblyEntry {
diff --git a/main/src/mill/modules/Jvm.scala b/main/src/mill/modules/Jvm.scala
index 4c26b297..b4a55de3 100644
--- a/main/src/mill/modules/Jvm.scala
+++ b/main/src/mill/modules/Jvm.scala
@@ -8,7 +8,6 @@ import java.nio.file.attribute.PosixFilePermission
import java.util.Collections
import java.util.jar.{JarEntry, JarFile, JarOutputStream}
-import ammonite.ops._
import coursier.{Cache, Dependency, Fetch, Repository, Resolution}
import coursier.util.{Gather, Task}
import geny.Generator
@@ -23,11 +22,11 @@ import scala.collection.JavaConverters._
object Jvm {
def interactiveSubprocess(mainClass: String,
- classPath: Agg[Path],
+ classPath: Agg[os.Path],
jvmArgs: Seq[String] = Seq.empty,
envArgs: Map[String, String] = Map.empty,
mainArgs: Seq[String] = Seq.empty,
- workingDir: Path = null,
+ workingDir: os.Path = null,
background: Boolean = false): Unit = {
val args =
Vector("java") ++
@@ -41,16 +40,16 @@ object Jvm {
def baseInteractiveSubprocess(commandArgs: Seq[String],
envArgs: Map[String, String],
- workingDir: Path) = {
+ workingDir: os.Path) = {
val process = baseInteractiveSubprocess0(commandArgs, envArgs, workingDir)
val exitCode = process.waitFor()
if (exitCode == 0) ()
- else throw InteractiveShelloutException()
+ else throw new Exception("Interactive Subprocess Failed")
}
def baseInteractiveSubprocess0(commandArgs: Seq[String],
envArgs: Map[String, String],
- workingDir: Path) = {
+ workingDir: os.Path) = {
val builder = new java.lang.ProcessBuilder()
for ((k, v) <- envArgs){
@@ -86,7 +85,7 @@ object Jvm {
def runLocal(mainClass: String,
- classPath: Agg[Path],
+ classPath: Agg[os.Path],
mainArgs: Seq[String] = Seq.empty)
(implicit ctx: Ctx): Unit = {
inprocess(classPath, classLoaderOverrideSbtTesting = false, isolated = true, closeContextClassLoaderWhenDone = true, cl => {
@@ -110,7 +109,7 @@ object Jvm {
- def inprocess[T](classPath: Agg[Path],
+ def inprocess[T](classPath: Agg[os.Path],
classLoaderOverrideSbtTesting: Boolean,
isolated: Boolean,
closeContextClassLoaderWhenDone: Boolean,
@@ -143,11 +142,11 @@ object Jvm {
}
def subprocess(mainClass: String,
- classPath: Agg[Path],
+ classPath: Agg[os.Path],
jvmArgs: Seq[String] = Seq.empty,
envArgs: Map[String, String] = Map.empty,
mainArgs: Seq[String] = Seq.empty,
- workingDir: Path = null)
+ workingDir: os.Path = null)
(implicit ctx: Ctx) = {
val commandArgs =
@@ -157,7 +156,7 @@ object Jvm {
mainArgs
val workingDir1 = Option(workingDir).getOrElse(ctx.dest)
- mkdir(workingDir1)
+ os.makeDir.all(workingDir1)
val builder =
new java.lang.ProcessBuilder()
.directory(workingDir1.toIO)
@@ -170,10 +169,10 @@ object Jvm {
val stdout = proc.getInputStream
val stderr = proc.getErrorStream
val sources = Seq(
- (stdout, Left(_: Bytes), ctx.log.outputStream),
- (stderr, Right(_: Bytes),ctx.log.errorStream )
+ (stdout, Left(_: os.Bytes), ctx.log.outputStream),
+ (stderr, Right(_: os.Bytes),ctx.log.errorStream )
)
- val chunks = mutable.Buffer.empty[Either[Bytes, Bytes]]
+ val chunks = mutable.Buffer.empty[Either[os.Bytes, os.Bytes]]
while(
// Process.isAlive doesn't exist on JDK 7 =/
util.Try(proc.exitValue).isFailure ||
@@ -186,7 +185,7 @@ object Jvm {
readSomething = true
val array = new Array[Byte](subStream.available())
val actuallyRead = subStream.read(array)
- chunks.append(wrapper(new ammonite.ops.Bytes(array)))
+ chunks.append(wrapper(new os.Bytes(array)))
parentStream.write(array, 0, actuallyRead)
}
}
@@ -195,8 +194,8 @@ object Jvm {
Thread.sleep(2)
}
- if (proc.exitValue() != 0) throw new InteractiveShelloutException()
- else ammonite.ops.CommandResult(proc.exitValue(), chunks)
+ if (proc.exitValue() != 0) throw new Exception("Subprocess failed")
+ else os.CommandResult(proc.exitValue(), chunks)
}
private def createManifest(mainClass: Option[String]) = {
@@ -214,42 +213,42 @@ object Jvm {
* called out.jar in the implicit ctx.dest folder. An optional main class may
* be provided for the jar. An optional filter function may also be provided to
* selectively include/exclude specific files.
- * @param inputPaths - `Agg` of `Path`s containing files to be included in the jar
+ * @param inputPaths - `Agg` of `os.Path`s containing files to be included in the jar
* @param mainClass - optional main class for the jar
* @param fileFilter - optional file filter to select files to be included.
- * Given a `Path` (from inputPaths) and a `RelPath` for the individual file,
+ * Given a `os.Path` (from inputPaths) and a `os.RelPath` for the individual file,
* return true if the file is to be included in the jar.
* @param ctx - implicit `Ctx.Dest` used to determine the output directory for the jar.
* @return - a `PathRef` for the created jar.
*/
- def createJar(inputPaths: Agg[Path],
+ def createJar(inputPaths: Agg[os.Path],
mainClass: Option[String] = None,
- fileFilter: (Path, RelPath) => Boolean = (p: Path, r: RelPath) => true)
+ fileFilter: (os.Path, os.RelPath) => Boolean = (p: os.Path, r: os.RelPath) => true)
(implicit ctx: Ctx.Dest): PathRef = {
val outputPath = ctx.dest / "out.jar"
- rm(outputPath)
+ os.remove.all(outputPath)
- val seen = mutable.Set.empty[RelPath]
- seen.add("META-INF" / "MANIFEST.MF")
+ val seen = mutable.Set.empty[os.RelPath]
+ seen.add(os.rel / "META-INF" / "MANIFEST.MF")
val jar = new JarOutputStream(
new FileOutputStream(outputPath.toIO),
createManifest(mainClass)
)
try{
- assert(inputPaths.forall(exists(_)))
+ assert(inputPaths.forall(os.exists(_)))
for{
p <- inputPaths
(file, mapping) <-
- if (p.isFile) Iterator(p -> empty/p.last)
- else ls.rec(p).filter(_.isFile).map(sub => sub -> sub.relativeTo(p))
+ if (os.isFile(p)) Iterator(p -> os.rel / p.last)
+ else os.walk(p).filter(os.isFile).map(sub => sub -> sub.relativeTo(p)).sorted
if !seen(mapping) && fileFilter(p, mapping)
} {
seen.add(mapping)
val entry = new JarEntry(mapping.toString)
- entry.setTime(file.mtime.toMillis)
+ entry.setTime(os.mtime(file))
jar.putNextEntry(entry)
- jar.write(read.bytes(file))
+ jar.write(os.read.bytes(file))
jar.closeEntry()
}
} finally {
@@ -259,17 +258,10 @@ object Jvm {
PathRef(outputPath)
}
- def newOutputStream(p: java.nio.file.Path, append: Boolean = false) = {
- val options =
- if(append) Seq(StandardOpenOption.APPEND)
- else Seq(StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE)
- Files.newOutputStream(p, options:_*)
- }
-
- def createAssembly(inputPaths: Agg[Path],
+ def createAssembly(inputPaths: Agg[os.Path],
mainClass: Option[String] = None,
prependShellScript: String = "",
- base: Option[Path] = None,
+ base: Option[os.Path] = None,
assemblyRules: Seq[Assembly.Rule] = Assembly.defaultRules)
(implicit ctx: Ctx.Dest with Ctx.Log): PathRef = {
@@ -279,7 +271,7 @@ object Jvm {
val hm = new java.util.HashMap[String, String]()
base match{
- case Some(b) => cp(b, tmp)
+ case Some(b) => os.copy(b, tmp)
case None => hm.put("create", "true")
}
@@ -288,23 +280,25 @@ object Jvm {
val manifest = createManifest(mainClass)
val manifestPath = zipFs.getPath(JarFile.MANIFEST_NAME)
Files.createDirectories(manifestPath.getParent)
- val manifestOut = newOutputStream(manifestPath)
+ val manifestOut = Files.newOutputStream(
+ manifestPath,
+ StandardOpenOption.TRUNCATE_EXISTING,
+ StandardOpenOption.CREATE
+ )
manifest.write(manifestOut)
manifestOut.close()
Assembly.groupAssemblyEntries(inputPaths, assemblyRules).view
- .map {
- case (mapping, aggregate) =>
- zipFs.getPath(mapping) -> aggregate
- }
.foreach {
- case (path, AppendEntry(entries)) =>
+ case (mapping, AppendEntry(entries)) =>
+ val path = zipFs.getPath(mapping)
val concatenated = new SequenceInputStream(
Collections.enumeration(entries.map(_.inputStream).asJava))
- writeEntry(path, concatenated, append = Files.exists(path))
- case (path, WriteOnceEntry(entry)) =>
+ writeEntry(os.Path(path), concatenated, append = true)
+ case (mapping, WriteOnceEntry(entry)) =>
+ val path = zipFs.getPath(mapping)
if (Files.notExists(path)) {
- writeEntry(path, entry.inputStream, append = false)
+ writeEntry(os.Path(path), entry.inputStream, append = false)
}
}
@@ -312,33 +306,36 @@ object Jvm {
val output = ctx.dest / "out.jar"
// Prepend shell script and make it executable
- if (prependShellScript.isEmpty) mv(tmp, output)
+ if (prependShellScript.isEmpty) os.move(tmp, output)
else{
val lineSep = if (!prependShellScript.endsWith("\n")) "\n\r\n" else ""
- val outputStream = newOutputStream(output.toNIO)
- IO.stream(new ByteArrayInputStream((prependShellScript + lineSep).getBytes()), outputStream)
- IO.stream(read.getInputStream(tmp), outputStream)
- outputStream.close()
+ os.write(
+ output,
+ Seq[os.Source](
+ prependShellScript + lineSep,
+ os.read.inputStream(tmp)
+ )
+ )
if (!scala.util.Properties.isWin) {
- val perms = Files.getPosixFilePermissions(output.toNIO)
- perms.add(PosixFilePermission.GROUP_EXECUTE)
- perms.add(PosixFilePermission.OWNER_EXECUTE)
- perms.add(PosixFilePermission.OTHERS_EXECUTE)
- Files.setPosixFilePermissions(output.toNIO, perms)
+ os.perms.set(
+ output,
+ os.perms(output)
+ + PosixFilePermission.GROUP_EXECUTE
+ + PosixFilePermission.OWNER_EXECUTE
+ + PosixFilePermission.OTHERS_EXECUTE
+ )
}
}
PathRef(output)
}
- private def writeEntry(p: java.nio.file.Path, is: InputStream, append: Boolean): Unit = {
- if (p.getParent != null) Files.createDirectories(p.getParent)
- val outputStream = newOutputStream(p, append)
-
- IO.stream(is, outputStream)
+ private def writeEntry(p: os.Path, is: InputStream, append: Boolean): Unit = {
+ if (p.toNIO.getParent != null) Files.createDirectories(p.toNIO.getParent)
+ if (append) os.write(p, is)
+ else os.write.append(p, is)
- outputStream.close()
is.close()
}
@@ -376,7 +373,7 @@ object Jvm {
)
}
def createLauncher(mainClass: String,
- classPath: Agg[Path],
+ classPath: Agg[os.Path],
jvmArgs: Seq[String])
(implicit ctx: Ctx.Dest)= {
val isWin = scala.util.Properties.isWin
@@ -387,7 +384,7 @@ object Jvm {
val outputPath = ctx.dest / (if (isBatch) "run.bat" else "run")
val classPathStrs = classPath.map(_.toString)
- write(outputPath, launcherUniversalScript(mainClass, classPathStrs, classPathStrs, jvmArgs))
+ os.write(outputPath, launcherUniversalScript(mainClass, classPathStrs, classPathStrs, jvmArgs))
if (!isWin) {
val perms = Files.getPosixFilePermissions(outputPath.toNIO)
@@ -454,7 +451,7 @@ object Jvm {
val (errors, successes) = load(sourceOrJar)
if(errors.isEmpty){
mill.Agg.from(
- successes.map(p => PathRef(Path(p), quick = true)).filter(_.path.ext == "jar")
+ successes.map(p => PathRef(os.Path(p), quick = true)).filter(_.path.ext == "jar")
)
}else{
val errorDetails = errors.map(e => s"${ammonite.util.Util.newLine} ${e.describe}").mkString
diff --git a/main/src/mill/modules/Util.scala b/main/src/mill/modules/Util.scala
index 38cd056b..2f57595e 100644
--- a/main/src/mill/modules/Util.scala
+++ b/main/src/mill/modules/Util.scala
@@ -1,14 +1,13 @@
package mill.modules
-import ammonite.ops.{Path, RelPath, empty, mkdir, read}
import coursier.Repository
import mill.eval.PathRef
import mill.util.{Ctx, IO, Loose}
object Util {
def cleanupScaladoc(v: String) = {
- v.lines.map(
+ v.linesIterator.map(
_.dropWhile(_.isWhitespace)
.stripPrefix("/**")
.stripPrefix("*/")
@@ -20,7 +19,7 @@ object Util {
.dropWhile(_.isEmpty)
.reverse
}
- def download(url: String, dest: RelPath = "download")(implicit ctx: Ctx.Dest) = {
+ def download(url: String, dest: os.RelPath = "download")(implicit ctx: Ctx.Dest) = {
val out = ctx.dest / dest
val website = new java.net.URI(url).toURL
@@ -38,26 +37,26 @@ object Util {
}
}
- def downloadUnpackZip(url: String, dest: RelPath = "unpacked")
+ def downloadUnpackZip(url: String, dest: os.RelPath = "unpacked")
(implicit ctx: Ctx.Dest) = {
- val tmpName = if (dest == empty / "tmp.zip") "tmp2.zip" else "tmp.zip"
+ val tmpName = if (dest == os.rel / "tmp.zip") "tmp2.zip" else "tmp.zip"
val downloaded = download(url, tmpName)
unpackZip(downloaded.path, dest)
}
- def unpackZip(src: Path, dest: RelPath = "unpacked")
+ def unpackZip(src: os.Path, dest: os.RelPath = "unpacked")
(implicit ctx: Ctx.Dest) = {
- val byteStream = read.getInputStream(src)
+ val byteStream = os.read.inputStream(src)
val zipStream = new java.util.zip.ZipInputStream(byteStream)
while({
zipStream.getNextEntry match{
case null => false
case entry =>
if (!entry.isDirectory) {
- val entryDest = ctx.dest / dest / RelPath(entry.getName)
- mkdir(entryDest / ammonite.ops.up)
+ val entryDest = ctx.dest / dest / os.RelPath(entry.getName)
+ os.makeDir.all(entryDest / ammonite.ops.up)
val fileOut = new java.io.FileOutputStream(entryDest.toString)
IO.stream(zipStream, fileOut)
fileOut.close()
@@ -72,12 +71,12 @@ object Util {
def millProjectModule(key: String,
artifact: String,
repositories: Seq[Repository],
- resolveFilter: Path => Boolean = _ => true,
+ resolveFilter: os.Path => Boolean = _ => true,
artifactSuffix: String = "_2.12") = {
val localPath = sys.props(key)
if (localPath != null) {
mill.eval.Result.Success(
- Loose.Agg.from(localPath.split(',').map(p => PathRef(Path(p), quick = true)))
+ Loose.Agg.from(localPath.split(',').map(p => PathRef(os.Path(p), quick = true)))
)
} else {
mill.modules.Jvm.resolveDependencies(
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)
}
diff --git a/main/test/src/mill/UTestFramework.scala b/main/test/src/mill/UTestFramework.scala
index 6c0d5191..c234151b 100644
--- a/main/test/src/mill/UTestFramework.scala
+++ b/main/test/src/mill/UTestFramework.scala
@@ -5,7 +5,7 @@ class UTestFramework extends utest.runner.Framework {
s.getClassName.startsWith("mill.")
}
override def setup() = {
- import ammonite.ops._
- rm(pwd / 'target / 'workspace)
+
+ os.remove.all(os.pwd / 'target / 'workspace)
}
}
diff --git a/main/test/src/mill/define/BasePathTests.scala b/main/test/src/mill/define/BasePathTests.scala
index d5167081..b8a653c8 100644
--- a/main/test/src/mill/define/BasePathTests.scala
+++ b/main/test/src/mill/define/BasePathTests.scala
@@ -2,7 +2,6 @@ package mill.define
import mill.util.{TestGraphs, TestUtil}
import utest._
-import ammonite.ops._
import mill.{Module, T}
object BasePathTests extends TestSuite{
val testGraphs = new TestGraphs
@@ -54,7 +53,7 @@ object BasePathTests extends TestSuite{
}
'overriden - {
object overridenBasePath extends TestUtil.BaseModule {
- override def millSourcePath = pwd / 'overridenBasePathRootValue
+ override def millSourcePath = os.pwd / 'overridenBasePathRootValue
object nested extends Module{
override def millSourcePath = super.millSourcePath / 'overridenBasePathNested
object nested extends Module{
@@ -63,9 +62,9 @@ object BasePathTests extends TestSuite{
}
}
assert(
- overridenBasePath.millSourcePath == pwd / 'overridenBasePathRootValue,
- overridenBasePath.nested.millSourcePath == pwd / 'overridenBasePathRootValue / 'nested / 'overridenBasePathNested,
- overridenBasePath.nested.nested.millSourcePath == pwd / 'overridenBasePathRootValue / 'nested / 'overridenBasePathNested / 'nested / 'overridenBasePathDoubleNested
+ overridenBasePath.millSourcePath == os.pwd / 'overridenBasePathRootValue,
+ overridenBasePath.nested.millSourcePath == os.pwd / 'overridenBasePathRootValue / 'nested / 'overridenBasePathNested,
+ overridenBasePath.nested.nested.millSourcePath == os.pwd / 'overridenBasePathRootValue / 'nested / 'overridenBasePathNested / 'nested / 'overridenBasePathDoubleNested
)
}
diff --git a/main/test/src/mill/define/CacherTests.scala b/main/test/src/mill/define/CacherTests.scala
index 98f2b7f8..84a8d840 100644
--- a/main/test/src/mill/define/CacherTests.scala
+++ b/main/test/src/mill/define/CacherTests.scala
@@ -1,6 +1,5 @@
package mill.define
-import ammonite.ops.pwd
import mill.util.{DummyLogger, TestEvaluator, TestUtil}
import mill.util.Strict.Agg
import mill.T
diff --git a/main/test/src/mill/eval/CrossTests.scala b/main/test/src/mill/eval/CrossTests.scala
index 3dec0222..f194924e 100644
--- a/main/test/src/mill/eval/CrossTests.scala
+++ b/main/test/src/mill/eval/CrossTests.scala
@@ -1,6 +1,6 @@
package mill.eval
-import ammonite.ops._
+
import mill.define.Discover
import mill.util.TestEvaluator
diff --git a/main/test/src/mill/eval/EvaluationTests.scala b/main/test/src/mill/eval/EvaluationTests.scala
index 75a5bbe3..74f9088c 100644
--- a/main/test/src/mill/eval/EvaluationTests.scala
+++ b/main/test/src/mill/eval/EvaluationTests.scala
@@ -9,7 +9,7 @@ import mill.util.Strict.Agg
import utest._
import utest.framework.TestPath
-import ammonite.ops._
+
object EvaluationTests extends TestSuite{
class Checker[T <: TestUtil.BaseModule](module: T)(implicit tp: TestPath) {
diff --git a/main/test/src/mill/eval/FailureTests.scala b/main/test/src/mill/eval/FailureTests.scala
index 22021079..bf45119c 100644
--- a/main/test/src/mill/eval/FailureTests.scala
+++ b/main/test/src/mill/eval/FailureTests.scala
@@ -1,7 +1,6 @@
package mill.eval
import mill.T
import mill.util.{TestEvaluator, TestUtil}
-import ammonite.ops.{Path, pwd, rm}
import mill.eval.Result.OuterStack
import utest._
import utest.framework.TestPath
diff --git a/main/test/src/mill/eval/JavaCompileJarTests.scala b/main/test/src/mill/eval/JavaCompileJarTests.scala
index d4bdbd87..8e931747 100644
--- a/main/test/src/mill/eval/JavaCompileJarTests.scala
+++ b/main/test/src/mill/eval/JavaCompileJarTests.scala
@@ -1,7 +1,5 @@
package mill.eval
-import ammonite.ops.ImplicitWd._
-import ammonite.ops._
import mill.define.{Discover, Input, Target, Task}
import mill.modules.Jvm
import mill.util.Ctx.Dest
@@ -12,19 +10,19 @@ import utest._
import mill._
object JavaCompileJarTests extends TestSuite{
def compileAll(sources: mill.util.Loose.Agg[PathRef])(implicit ctx: Dest) = {
- mkdir(ctx.dest)
- import ammonite.ops._
- %("javac", sources.map(_.path.toString()).toSeq, "-d", ctx.dest)(wd = ctx.dest)
+ os.makeDir.all(ctx.dest)
+
+ os.proc("javac", sources.map(_.path.toString()).toSeq, "-d", ctx.dest).call(ctx.dest)
PathRef(ctx.dest)
}
val tests = Tests{
'javac {
- val javacSrcPath = pwd / 'main / 'test / 'resources / 'examples / 'javac
+ val javacSrcPath = os.pwd / 'main / 'test / 'resources / 'examples / 'javac
val javacDestPath = TestUtil.getOutPath() / 'src
- mkdir(javacDestPath / up)
- cp(javacSrcPath, javacDestPath)
+ os.makeDir.all(javacDestPath / os.up)
+ os.copy(javacSrcPath, javacDestPath)
object Build extends TestUtil.BaseModule{
def sourceRootPath = javacDestPath / 'src
@@ -36,14 +34,14 @@ object JavaCompileJarTests extends TestSuite{
// 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)) }
// Test createJar() with optional file filter.
- def filterJar(fileFilter: (Path, RelPath) => Boolean) = T{ Jvm.createJar(Loose.Agg(classFiles().path) ++ resourceRoot().map(_.path), None, fileFilter) }
+ def filterJar(fileFilter: (os.Path, os.RelPath) => Boolean) = T{ Jvm.createJar(Loose.Agg(classFiles().path) ++ resourceRoot().map(_.path), None, fileFilter) }
def run(mainClsName: String) = T.command{
- %%('java, "-Duser.language=en", "-cp", classFiles().path, mainClsName)
+ os.proc('java, "-Duser.language=en", "-cp", classFiles().path, mainClsName).call()
}
}
@@ -57,7 +55,7 @@ object JavaCompileJarTests extends TestSuite{
evaluator.check(targets, expected)
}
- def append(path: Path, txt: String) = ammonite.ops.write.append(path, txt)
+ def append(path: os.Path, txt: String) = ammonite.ops.write.append(path, txt)
check(
@@ -67,7 +65,6 @@ object JavaCompileJarTests extends TestSuite{
// Re-running with no changes results in nothing being evaluated
check(targets = Agg(jar), expected = Agg())
-
// Appending an empty string gets ignored due to file-content hashing
append(sourceRootPath / "Foo.java", "")
check(targets = Agg(jar), expected = Agg())
@@ -106,7 +103,7 @@ object JavaCompileJarTests extends TestSuite{
check(targets = Agg(allSources), expected = Agg(allSources))
check(targets = Agg(jar), expected = Agg(classFiles, jar))
- val jarContents = %%('jar, "-tf", evaluator.outPath/'jar/'dest/"out.jar")(evaluator.outPath).out.string
+ val jarContents = os.proc('jar, "-tf", evaluator.outPath/'jar/'dest/"out.jar").call(evaluator.outPath).out.string
val expectedJarContents =
"""META-INF/MANIFEST.MF
|test/Bar.class
@@ -116,16 +113,16 @@ object JavaCompileJarTests extends TestSuite{
|test/FooTwo.class
|hello.txt
|""".stripMargin
- assert(jarContents.lines.toSeq == expectedJarContents.lines.toSeq)
+ assert(jarContents.linesIterator.toSeq == expectedJarContents.linesIterator.toSeq)
// Create the Jar again, but this time, filter out the Foo files.
def noFoos(s: String) = !s.contains("Foo")
- val filterFunc = (p: Path, r: RelPath) => noFoos(r.last)
+ val filterFunc = (p: os.Path, r: os.RelPath) => noFoos(r.last)
eval(filterJar(filterFunc))
- val filteredJarContents = %%('jar, "-tf", evaluator.outPath/'filterJar/'dest/"out.jar")(evaluator.outPath).out.string
- assert(filteredJarContents.lines.toSeq == expectedJarContents.lines.filter(noFoos(_)).toSeq)
+ val filteredJarContents = os.proc('jar, "-tf", evaluator.outPath/'filterJar/'dest/"out.jar").call(evaluator.outPath).out.string
+ assert(filteredJarContents.linesIterator.toSeq == expectedJarContents.linesIterator.filter(noFoos(_)).toSeq)
- val executed = %%('java, "-cp", evaluator.outPath/'jar/'dest/"out.jar", "test.Foo")(evaluator.outPath).out.string
+ val executed = os.proc('java, "-cp", evaluator.outPath/'jar/'dest/"out.jar", "test.Foo").call(evaluator.outPath).out.string
assert(executed == (31337 + 271828) + System.lineSeparator)
for(i <- 0 until 3){
diff --git a/main/test/src/mill/eval/ModuleTests.scala b/main/test/src/mill/eval/ModuleTests.scala
index 0b4a7c80..f28fc9b6 100644
--- a/main/test/src/mill/eval/ModuleTests.scala
+++ b/main/test/src/mill/eval/ModuleTests.scala
@@ -1,6 +1,6 @@
package mill.eval
-import ammonite.ops._
+
import mill.util.{TestEvaluator, TestUtil}
import mill.T
import mill.define.Discover
@@ -19,15 +19,15 @@ object ModuleTests extends TestSuite{
def z = T{ ExternalModule.x() + ExternalModule.inner.y() }
}
val tests = Tests {
- rm(TestEvaluator.externalOutPath)
+ os.remove.all(TestEvaluator.externalOutPath)
'externalModuleTargetsAreNamespacedByModulePackagePath - {
val check = new TestEvaluator(Build)
val zresult = check.apply(Build.z)
assert(
zresult == Right((30, 1)),
- read(check.evaluator.outPath / 'z / "meta.json").contains("30"),
- read(TestEvaluator.externalOutPath / 'mill / 'eval / 'ModuleTests / 'ExternalModule / 'x / "meta.json").contains("13"),
- read(TestEvaluator.externalOutPath / 'mill / 'eval / 'ModuleTests / 'ExternalModule / 'inner / 'y / "meta.json").contains("17")
+ os.read(check.evaluator.outPath / 'z / "meta.json").contains("30"),
+ os.read(TestEvaluator.externalOutPath / 'mill / 'eval / 'ModuleTests / 'ExternalModule / 'x / "meta.json").contains("13"),
+ os.read(TestEvaluator.externalOutPath / 'mill / 'eval / 'ModuleTests / 'ExternalModule / 'inner / 'y / "meta.json").contains("17")
)
}
'externalModuleMustBeGlobalStatic - {
diff --git a/main/test/src/mill/eval/TaskTests.scala b/main/test/src/mill/eval/TaskTests.scala
index 4ba65e17..0bfd8efc 100644
--- a/main/test/src/mill/eval/TaskTests.scala
+++ b/main/test/src/mill/eval/TaskTests.scala
@@ -1,7 +1,7 @@
package mill.eval
import utest._
-import ammonite.ops._
+
import mill.T
import mill.util.TestEvaluator
@@ -34,15 +34,15 @@ object TaskTests extends TestSuite{
def persistent = T.persistent{
input() // force re-computation
- mkdir(T.ctx().dest)
- write.append(T.ctx().dest/'count, "hello\n")
- read.lines(T.ctx().dest/'count).length
+ os.makeDir.all(T.ctx().dest)
+ os.write.append(T.ctx().dest/'count, "hello\n")
+ os.read.lines(T.ctx().dest/'count).length
}
def nonPersistent = T{
input() // force re-computation
- mkdir(T.ctx().dest)
- write.append(T.ctx().dest/'count, "hello\n")
- read.lines(T.ctx().dest/'count).length
+ os.makeDir.all(T.ctx().dest)
+ os.write.append(T.ctx().dest/'count, "hello\n")
+ os.read.lines(T.ctx().dest/'count).length
}
def staticWorkerDownstream = T{
diff --git a/main/test/src/mill/main/ClientServerTests.scala b/main/test/src/mill/main/ClientServerTests.scala
index 2462f650..05238a5f 100644
--- a/main/test/src/mill/main/ClientServerTests.scala
+++ b/main/test/src/mill/main/ClientServerTests.scala
@@ -1,6 +1,5 @@
package mill.main
import java.io._
-import java.nio.file.Path
import mill.main.client.{Util, Locks}
@@ -47,7 +46,7 @@ object ClientServerTests extends TestSuite{
(tmpDir, locks)
}
- def spawnEchoServer(tmpDir : Path, locks: Locks): Unit = {
+ def spawnEchoServer(tmpDir : java.nio.file.Path, locks: Locks): Unit = {
new Thread(() => new Server(
tmpDir.toString,
new EchoServer(),
@@ -57,7 +56,7 @@ object ClientServerTests extends TestSuite{
).run()).start()
}
- def runClientAux(tmpDir : Path, locks: Locks)
+ def runClientAux(tmpDir : java.nio.file.Path, locks: Locks)
(env : Map[String, String], args: Array[String]) = {
val (in, out, err) = initStreams()
Server.lockBlock(locks.clientLock){
diff --git a/main/test/src/mill/main/ForeignBuildsTest.scala b/main/test/src/mill/main/ForeignBuildsTest.scala
index 085ada02..cfc8d00c 100644
--- a/main/test/src/mill/main/ForeignBuildsTest.scala
+++ b/main/test/src/mill/main/ForeignBuildsTest.scala
@@ -1,14 +1,13 @@
package mill.main
-import ammonite.ops._
import mill.util.ScriptTestSuite
import utest._
object ForeignBuildsTest extends ScriptTestSuite(fork = false) {
def workspaceSlug = "foreign-builds"
def scriptSourcePath =
- pwd / 'main / 'test / 'resources / 'examples / 'foreign
- override def buildPath = 'project / "build.sc"
+ os.pwd / 'main / 'test / 'resources / 'examples / 'foreign
+ override def buildPath = os.rel / 'project / "build.sc"
val tests = Tests {
initWorkspace()
diff --git a/main/test/src/mill/main/ForeignConflictTest.scala b/main/test/src/mill/main/ForeignConflictTest.scala
index c5d99c9f..a4352bb6 100644
--- a/main/test/src/mill/main/ForeignConflictTest.scala
+++ b/main/test/src/mill/main/ForeignConflictTest.scala
@@ -1,14 +1,14 @@
package mill.main
-import ammonite.ops._
+
import mill.util.ScriptTestSuite
import utest._
object ForeignConflictTest extends ScriptTestSuite(fork = false) {
def workspaceSlug = "foreign-conflict"
def scriptSourcePath =
- pwd / 'main / 'test / 'resources / 'examples / 'foreign
- override def buildPath = 'conflict / "build.sc"
+ os.pwd / 'main / 'test / 'resources / 'examples / 'foreign
+ override def buildPath = os.rel / 'conflict / "build.sc"
val tests = Tests {
initWorkspace()
diff --git a/main/test/src/mill/main/JavaCompileJarTests.scala b/main/test/src/mill/main/JavaCompileJarTests.scala
index 6c45b454..37c64b05 100644
--- a/main/test/src/mill/main/JavaCompileJarTests.scala
+++ b/main/test/src/mill/main/JavaCompileJarTests.scala
@@ -1,12 +1,11 @@
package mill.main
-import ammonite.ops._
import mill.util.ScriptTestSuite
import utest._
object JavaCompileJarTests extends ScriptTestSuite(fork = false) {
def workspaceSlug = "java-compile-jar"
- def scriptSourcePath = pwd / 'main / 'test / 'resources / 'examples / 'javac
+ def scriptSourcePath = os.pwd / 'main / 'test / 'resources / 'examples / 'javac
val tests = Tests{
initWorkspace()
'test - {
@@ -31,8 +30,8 @@ object JavaCompileJarTests extends ScriptTestSuite(fork = false) {
)
// If we update resources, classFiles are unchanged but jar changes
- for(scalaFile <- ls.rec(workspacePath).filter(_.ext == "txt")){
- write.append(scalaFile, "\n")
+ for(scalaFile <- os.walk(workspacePath).filter(_.ext == "txt")){
+ os.write.append(scalaFile, "\n")
}
assert(eval("classFiles"))
@@ -48,15 +47,15 @@ object JavaCompileJarTests extends ScriptTestSuite(fork = false) {
// We can intentionally break the code, have the targets break, then
// fix the code and have them recover.
- for(scalaFile <- ls.rec(workspacePath).filter(_.ext == "java")){
- write.append(scalaFile, "\n}")
+ for(scalaFile <- os.walk(workspacePath).filter(_.ext == "java")){
+ os.write.append(scalaFile, "\n}")
}
assert(!eval("classFiles"))
assert(!eval("jar"))
- for(scalaFile <- ls.rec(workspacePath).filter(_.ext == "java")){
- write.over(scalaFile, read(scalaFile).dropRight(2))
+ for(scalaFile <- os.walk(workspacePath).filter(_.ext == "java")){
+ os.write.over(scalaFile, os.read(scalaFile).dropRight(2))
}
assert(eval("classFiles"))
diff --git a/main/test/src/mill/util/ScriptTestSuite.scala b/main/test/src/mill/util/ScriptTestSuite.scala
index 9d3edb65..b324f94c 100644
--- a/main/test/src/mill/util/ScriptTestSuite.scala
+++ b/main/test/src/mill/util/ScriptTestSuite.scala
@@ -2,16 +2,15 @@ package mill.util
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, PrintStream}
-import ammonite.ops._
import utest._
abstract class ScriptTestSuite(fork: Boolean) extends TestSuite{
def workspaceSlug: String
- def scriptSourcePath: Path
- def buildPath: RelPath = "build.sc"
+ def scriptSourcePath: os.Path
+ def buildPath: os.RelPath = "build.sc"
- val workspacePath = pwd / 'target / 'workspace / workspaceSlug
- val wd = workspacePath / buildPath / up
+ val workspacePath = os.pwd / 'target / 'workspace / workspaceSlug
+ val wd = workspacePath / buildPath / os.up
val stdOutErr = new PrintStream(new ByteArrayOutputStream())
val stdIn = new ByteArrayInputStream(Array())
val disableTicker = false
@@ -25,7 +24,7 @@ abstract class ScriptTestSuite(fork: Boolean) extends TestSuite{
if (!fork) runner.runScript(workspacePath / buildPath , s.toList)
else{
try {
- %(home / "mill-release", "-i", s)(wd)
+ os.proc(os.home / "mill-release", "-i", s).call(wd)
true
}catch{case e: Throwable => false}
}
@@ -33,17 +32,17 @@ abstract class ScriptTestSuite(fork: Boolean) extends TestSuite{
def meta(s: String) = {
val (List(selector), args) = ParseArgs.apply(Seq(s), multiSelect = false).right.get
- read(wd / "out" / selector._2.value.flatMap(_.pathSegments) / "meta.json")
+ os.read(wd / "out" / selector._2.value.flatMap(_.pathSegments) / "meta.json")
}
def initWorkspace() = {
- rm(workspacePath)
- mkdir(workspacePath / up)
+ os.remove.all(workspacePath)
+ os.makeDir.all(workspacePath / os.up)
// The unzipped git repo snapshots we get from github come with a
// wrapper-folder inside the zip file, so copy the wrapper folder to the
// destination instead of the folder containing the wrapper.
- cp(scriptSourcePath, workspacePath)
+ os.copy(scriptSourcePath, workspacePath)
}
}
diff --git a/main/test/src/mill/util/TestEvaluator.scala b/main/test/src/mill/util/TestEvaluator.scala
index 6e7fe484..67ba96dc 100644
--- a/main/test/src/mill/util/TestEvaluator.scala
+++ b/main/test/src/mill/util/TestEvaluator.scala
@@ -1,6 +1,5 @@
package mill.util
-import ammonite.ops.pwd
import mill.define.{Input, Target, Task}
import mill.eval.Result.OuterStack
import mill.eval.{Evaluator, Result}
@@ -10,7 +9,7 @@ import utest.framework.TestPath
import language.experimental.macros
object TestEvaluator{
- val externalOutPath = pwd / 'target / 'external
+ val externalOutPath = os.pwd / 'target / 'external
def static(module: TestUtil.BaseModule)(implicit fullName: sourcecode.FullName) = {
diff --git a/main/test/src/mill/util/TestUtil.scala b/main/test/src/mill/util/TestUtil.scala
index b4e3af89..e5fe906e 100644
--- a/main/test/src/mill/util/TestUtil.scala
+++ b/main/test/src/mill/util/TestUtil.scala
@@ -1,7 +1,6 @@
package mill.util
import mill.util.Router.Overrides
-import ammonite.ops.pwd
import mill.define._
import mill.eval.Result
import mill.eval.Result.OuterStack
@@ -14,17 +13,17 @@ import scala.collection.mutable
object TestUtil {
def getOutPath()(implicit fullName: sourcecode.FullName,
tp: TestPath) = {
- pwd / 'target / 'workspace / (fullName.value.split('.') ++ tp.value)
+ os.pwd / 'target / 'workspace / (fullName.value.split('.') ++ tp.value)
}
def getOutPathStatic()(implicit fullName: sourcecode.FullName) = {
- pwd / 'target / 'workspace / fullName.value.split('.')
+ os.pwd / 'target / 'workspace / fullName.value.split('.')
}
def getSrcPathStatic()(implicit fullName: sourcecode.FullName) = {
- pwd / 'target / 'worksources / fullName.value.split('.')
+ os.pwd / 'target / 'worksources / fullName.value.split('.')
}
def getSrcPathBase() = {
- pwd / 'target / 'worksources
+ os.pwd / 'target / 'worksources
}
class BaseModule(implicit millModuleEnclosing0: sourcecode.Enclosing,
diff --git a/readme.md b/readme.md
index dd05d0c0..a87fba0d 100644
--- a/readme.md
+++ b/readme.md
@@ -117,7 +117,7 @@ In case of troubles with caching and/or incremental compilation, you can always
restart from scratch removing the `out` directory:
```bash
-rm -rf out/
+os.remove.all -rf out/
```
## Project Layout
diff --git a/scalajslib/src/mill/scalajslib/ScalaJSModule.scala b/scalajslib/src/mill/scalajslib/ScalaJSModule.scala
index e0ee55a5..37537a85 100644
--- a/scalajslib/src/mill/scalajslib/ScalaJSModule.scala
+++ b/scalajslib/src/mill/scalajslib/ScalaJSModule.scala
@@ -1,7 +1,6 @@
package mill
package scalajslib
-import ammonite.ops.{Path, exists, ls, mkdir, rm}
import coursier.Cache
import coursier.maven.MavenRepository
import mill.eval.{PathRef, Result}
@@ -108,13 +107,13 @@ trait ScalaJSModule extends scalalib.ScalaModule { outer =>
moduleKind: ModuleKind)(implicit ctx: Ctx): Result[PathRef] = {
val outputPath = ctx.dest / "out.js"
- mkdir(ctx.dest)
- rm(outputPath)
+ os.makeDir.all(ctx.dest)
+ os.remove.all(outputPath)
val classpath = runClasspath.map(_.path)
val sjsirFiles = classpath
- .filter(path => exists(path) && path.isDir)
- .flatMap(ls.rec)
+ .filter(path => os.exists(path) && os.isDir(path))
+ .flatMap(os.walk(_))
.filter(_.ext == "sjsir")
val libraries = classpath.filter(_.ext == "jar")
worker.link(
diff --git a/scalajslib/src/mill/scalajslib/ScalaJSWorkerApi.scala b/scalajslib/src/mill/scalajslib/ScalaJSWorkerApi.scala
index 552aa572..881a65b9 100644
--- a/scalajslib/src/mill/scalajslib/ScalaJSWorkerApi.scala
+++ b/scalajslib/src/mill/scalajslib/ScalaJSWorkerApi.scala
@@ -3,7 +3,6 @@ package mill.scalajslib
import java.io.File
import java.net.URLClassLoader
-import ammonite.ops.Path
import mill.define.Discover
import mill.eval.Result
import mill.util.Ctx
@@ -23,10 +22,10 @@ object ModuleKind{
class ScalaJSWorker {
private var scalaInstanceCache = Option.empty[(Long, ScalaJSWorkerApi)]
- private def bridge(toolsClasspath: Agg[Path])
+ private def bridge(toolsClasspath: Agg[os.Path])
(implicit ctx: Ctx.Home) = {
val classloaderSig =
- toolsClasspath.map(p => p.toString().hashCode + p.mtime.toMillis).sum
+ toolsClasspath.map(p => p.toString().hashCode + os.mtime(p)).sum
scalaInstanceCache match {
case Some((sig, bridge)) if sig == classloaderSig => bridge
case _ =>
@@ -44,14 +43,14 @@ class ScalaJSWorker {
}
}
- def link(toolsClasspath: Agg[Path],
- sources: Agg[Path],
- libraries: Agg[Path],
+ def link(toolsClasspath: Agg[os.Path],
+ sources: Agg[os.Path],
+ libraries: Agg[os.Path],
dest: File,
main: Option[String],
fullOpt: Boolean,
moduleKind: ModuleKind)
- (implicit ctx: Ctx.Home): Result[Path] = {
+ (implicit ctx: Ctx.Home): Result[os.Path] = {
bridge(toolsClasspath).link(
sources.items.map(_.toIO).toArray,
libraries.items.map(_.toIO).toArray,
@@ -59,15 +58,15 @@ class ScalaJSWorker {
main.orNull,
fullOpt,
moduleKind
- ).map(Path(_))
+ ).map(os.Path(_))
}
- def run(toolsClasspath: Agg[Path], config: NodeJSConfig, linkedFile: File)
+ def run(toolsClasspath: Agg[os.Path], config: NodeJSConfig, linkedFile: File)
(implicit ctx: Ctx.Home): Unit = {
bridge(toolsClasspath).run(config, linkedFile)
}
- def getFramework(toolsClasspath: Agg[Path],
+ def getFramework(toolsClasspath: Agg[os.Path],
config: NodeJSConfig,
frameworkName: String,
linkedFile: File)
diff --git a/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala b/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala
index cfdcdd1f..7b1027e8 100644
--- a/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala
+++ b/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala
@@ -1,8 +1,6 @@
package mill.scalajslib
import java.util.jar.JarFile
-
-import ammonite.ops._
import mill._
import mill.define.Discover
import mill.eval.{Evaluator, Result}
@@ -71,7 +69,7 @@ object HelloJSWorldTests extends TestSuite {
override lazy val millDiscover = Discover[this.type]
}
- val millSourcePath = pwd / 'scalajslib / 'test / 'resources / "hello-js-world"
+ val millSourcePath = os.pwd / 'scalajslib / 'test / 'resources / "hello-js-world"
val helloWorldEvaluator = TestEvaluator.static(HelloJSWorld)
@@ -87,7 +85,7 @@ object HelloJSWorldTests extends TestSuite {
helloWorldEvaluator(HelloJSWorld.helloJsWorld(scalaVersion, scalaJSVersion).compile)
val outPath = result.classes.path
- val outputFiles = ls.rec(outPath)
+ val outputFiles = os.walk(outPath)
val expectedClassfiles = compileClassfiles(outPath)
assert(
outputFiles.toSet == expectedClassfiles,
@@ -213,7 +211,7 @@ object HelloJSWorldTests extends TestSuite {
helloWorldEvaluator.outPath,
task.ctx.segments
)
- val log = read(paths.log)
+ val log = os.read(paths.log)
assert(
evalCount > 0,
log.contains("node"),
@@ -229,7 +227,7 @@ object HelloJSWorldTests extends TestSuite {
}
}
- def compileClassfiles(parentDir: Path) = Set(
+ def compileClassfiles(parentDir: os.Path) = Set(
parentDir / "ArgsParser$.class",
parentDir / "ArgsParser$.sjsir",
parentDir / "ArgsParser.class",
@@ -241,9 +239,9 @@ object HelloJSWorldTests extends TestSuite {
)
def prepareWorkspace(): Unit = {
- rm(workspacePath)
- mkdir(workspacePath / up)
- cp(millSourcePath, workspacePath)
+ os.remove.all(workspacePath)
+ os.makeDir.all(workspacePath / os.up)
+ os.copy(millSourcePath, workspacePath)
}
}
diff --git a/scalajslib/test/src/mill/scalajslib/MultiModuleTests.scala b/scalajslib/test/src/mill/scalajslib/MultiModuleTests.scala
index 37429038..751c7537 100644
--- a/scalajslib/test/src/mill/scalajslib/MultiModuleTests.scala
+++ b/scalajslib/test/src/mill/scalajslib/MultiModuleTests.scala
@@ -1,6 +1,5 @@
package mill.scalajslib
-import ammonite.ops._
import mill._
import mill.define.Discover
import mill.eval.Evaluator
@@ -10,7 +9,7 @@ import utest._
object MultiModuleTests extends TestSuite {
val workspacePath = TestUtil.getOutPathStatic() / "multi-module"
- val sourcePath = pwd / 'scalajslib / 'test / 'resources / "multi-module"
+ val sourcePath = os.pwd / 'scalajslib / 'test / 'resources / "multi-module"
object MultiModule extends TestUtil.BaseModule {
trait BaseModule extends ScalaJSModule {
@@ -76,7 +75,7 @@ object MultiModuleTests extends TestSuite {
evaluator.outPath,
command.ctx.segments
)
- val log = read(paths.log)
+ val log = os.read(paths.log)
assert(
evalCount > 0,
log.contains("node"),
@@ -86,9 +85,9 @@ object MultiModuleTests extends TestSuite {
}
def prepareWorkspace(): Unit = {
- rm(workspacePath)
- mkdir(workspacePath / up)
- cp(sourcePath, workspacePath)
+ os.remove.all(workspacePath)
+ os.makeDir.all(workspacePath / os.up)
+ os.copy(sourcePath, workspacePath)
}
}
diff --git a/scalajslib/test/src/mill/scalajslib/NodeJSConfigTests.scala b/scalajslib/test/src/mill/scalajslib/NodeJSConfigTests.scala
index 5aef8dad..27ea0a13 100644
--- a/scalajslib/test/src/mill/scalajslib/NodeJSConfigTests.scala
+++ b/scalajslib/test/src/mill/scalajslib/NodeJSConfigTests.scala
@@ -1,6 +1,5 @@
package mill.scalajslib
-import ammonite.ops._
import mill._
import mill.define.Discover
import mill.eval.Evaluator
@@ -53,7 +52,7 @@ object NodeJSConfigTests extends TestSuite {
override lazy val millDiscover = Discover[this.type]
}
- val millSourcePath = pwd / 'scalajslib / 'test / 'resources / "hello-js-world"
+ val millSourcePath = os.pwd / 'scalajslib / 'test / 'resources / "hello-js-world"
val helloWorldEvaluator = TestEvaluator.static(HelloJSWorld)
@@ -68,7 +67,7 @@ object NodeJSConfigTests extends TestSuite {
helloWorldEvaluator.outPath,
command.ctx.segments
)
- val log = read(paths.log)
+ val log = os.read(paths.log)
assert(
nodeArgs.forall(log.contains),
notNodeArgs.forall(!log.contains(_))
@@ -96,9 +95,9 @@ object NodeJSConfigTests extends TestSuite {
}
def prepareWorkspace(): Unit = {
- rm(workspacePath)
- mkdir(workspacePath / up)
- cp(millSourcePath, workspacePath)
+ os.remove.all(workspacePath)
+ os.makeDir.all(workspacePath / os.up)
+ os.copy(millSourcePath, workspacePath)
}
}
diff --git a/scalajslib/test/src/mill/scalajslib/ScalaJsUtils.scala b/scalajslib/test/src/mill/scalajslib/ScalaJsUtils.scala
index 859d2d56..68f2f7ee 100644
--- a/scalajslib/test/src/mill/scalajslib/ScalaJsUtils.scala
+++ b/scalajslib/test/src/mill/scalajslib/ScalaJsUtils.scala
@@ -3,10 +3,8 @@ package mill.scalajslib
import java.io.{FileReader, StringWriter}
import javax.script.{ScriptContext, ScriptEngineManager}
-import ammonite.ops.Path
-
object ScalaJsUtils {
- def runJS(path: Path): String = {
+ def runJS(path: os.Path): String = {
val engineManager = new ScriptEngineManager(null)
val engine = engineManager.getEngineByName("nashorn")
val console = new Console
diff --git a/scalalib/src/mill/scalalib/GenIdeaImpl.scala b/scalalib/src/mill/scalalib/GenIdeaImpl.scala
index b4f77f16..87b039df 100644
--- a/scalalib/src/mill/scalalib/GenIdeaImpl.scala
+++ b/scalalib/src/mill/scalalib/GenIdeaImpl.scala
@@ -1,6 +1,5 @@
package mill.scalalib
-import ammonite.ops._
import ammonite.runtime.SpecialClassLoader
import coursier.{Cache, CoursierPaths, Repository}
import mill.define._
@@ -34,21 +33,21 @@ object GenIdeaImpl {
discover: Discover[_]): Unit = {
val pp = new scala.xml.PrettyPrinter(999, 4)
- val jdkInfo = extractCurrentJdk(pwd / ".idea" / "misc.xml").getOrElse(("JDK_1_8", "1.8 (1)"))
+ val jdkInfo = extractCurrentJdk(os.pwd / ".idea" / "misc.xml").getOrElse(("JDK_1_8", "1.8 (1)"))
- rm! pwd/".idea"/"libraries"
- rm! pwd/".idea"/"scala_compiler.xml"
- rm! pwd/".idea_modules"
+ os.remove.all(os.pwd/".idea"/"libraries")
+ os.remove.all(os.pwd/".idea"/"scala_compiler.xml")
+ os.remove.all(os.pwd/".idea_modules")
- val evaluator = new Evaluator(ctx.home, pwd / 'out, pwd / 'out, rootModule, ctx.log)
+ val evaluator = new Evaluator(ctx.home, os.pwd / 'out, os.pwd / 'out, rootModule, ctx.log)
for((relPath, xml) <- xmlFileLayout(evaluator, rootModule, jdkInfo)){
- write.over(pwd/relPath, pp.format(xml))
+ os.write.over(os.pwd/relPath, pp.format(xml))
}
}
- def extractCurrentJdk(ideaPath: Path): Option[(String,String)] = {
+ def extractCurrentJdk(ideaPath: os.Path): Option[(String,String)] = {
import scala.xml.XML
Try {
val xml = XML.loadFile(ideaPath.toString)
@@ -62,7 +61,7 @@ object GenIdeaImpl {
def xmlFileLayout(evaluator: Evaluator,
rootModule: mill.Module,
jdkInfo: (String,String),
- fetchMillModules: Boolean = true): Seq[(RelPath, scala.xml.Node)] = {
+ fetchMillModules: Boolean = true): Seq[(os.RelPath, scala.xml.Node)] = {
val modules = rootModule.millInternal.segmentsToModules.values
.collect{ case x: scalalib.JavaModule => (x.millModuleSegments, x)}
@@ -71,7 +70,7 @@ object GenIdeaImpl {
val buildLibraryPaths =
if (!fetchMillModules) Nil
else sys.props.get("MILL_BUILD_LIBRARIES") match {
- case Some(found) => found.split(',').map(Path(_)).distinct.toList
+ case Some(found) => found.split(',').map(os.Path(_)).distinct.toList
case None =>
val repos = modules.foldLeft(Set.empty[Repository]) { _ ++ _._2.repositories }
val artifactNames = Seq("main-moduledefs", "main-core", "scalalib", "scalajslib")
@@ -91,7 +90,7 @@ object GenIdeaImpl {
.asInstanceOf[SpecialClassLoader]
).map {
_.allJars
- .map(url => Path(url.getFile))
+ .map(url => os.Path(url.getFile))
.filter(_.toIO.exists)
}.getOrElse(Seq())
@@ -138,8 +137,8 @@ object GenIdeaImpl {
val commonPrefix =
if (allResolved.isEmpty) 0
else {
- val minResolvedLength = allResolved.map(_.segments.length).min
- allResolved.map(_.segments.take(minResolvedLength))
+ val minResolvedLength = allResolved.map(_.segmentCount).min
+ allResolved.map(_.segments.take(minResolvedLength).toList)
.transpose
.takeWhile(_.distinct.length == 1)
.length
@@ -148,37 +147,37 @@ object GenIdeaImpl {
// only resort to full long path names if the jar name is a duplicate
val pathShortLibNameDuplicate = allResolved
.distinct
- .map{p => p.segments.last -> p}
+ .map{p => p.last -> p}
.groupBy(_._1)
.filter(_._2.size > 1)
.keySet
val pathToLibName = allResolved
.map{p =>
- if (pathShortLibNameDuplicate(p.segments.last))
+ if (pathShortLibNameDuplicate(p.last))
(p, p.segments.drop(commonPrefix).mkString("_"))
else
- (p, p.segments.last)
+ (p, p.last)
}
.toMap
- sealed trait ResolvedLibrary { def path : Path }
- case class CoursierResolved(path : Path, pom : Path, sources : Option[Path])
+ sealed trait ResolvedLibrary { def path : os.Path }
+ case class CoursierResolved(path : os.Path, pom : os.Path, sources : Option[os.Path])
extends ResolvedLibrary
- case class OtherResolved(path : Path) extends ResolvedLibrary
+ case class OtherResolved(path : os.Path) extends ResolvedLibrary
// Tries to group jars with their poms and sources.
- def toResolvedJar(path : Path) : Option[ResolvedLibrary] = {
- val inCoursierCache = path.startsWith(Path(CoursierPaths.cacheDirectory()))
- val isSource = path.segments.last.endsWith("sources.jar")
+ def toResolvedJar(path : os.Path) : Option[ResolvedLibrary] = {
+ val inCoursierCache = path.startsWith(os.Path(CoursierPaths.cacheDirectory()))
+ val isSource = path.last.endsWith("sources.jar")
val isPom = path.ext == "pom"
if (inCoursierCache && (isSource || isPom)) {
// Remove sources and pom as they'll be recovered from the jar path
None
} else if (inCoursierCache && path.ext == "jar") {
- val withoutExt = path.segments.last.dropRight(path.ext.length + 1)
- val pom = path / up / s"$withoutExt.pom"
- val sources = Some(path / up / s"$withoutExt-sources.jar")
+ val withoutExt = path.last.dropRight(path.ext.length + 1)
+ val pom = path / os.up / s"$withoutExt.pom"
+ val sources = Some(path / os.up / s"$withoutExt-sources.jar")
.filter(_.toIO.exists())
Some(CoursierResolved(path, pom, sources))
} else Some(OtherResolved(path))
@@ -186,7 +185,7 @@ object GenIdeaImpl {
// Hack so that Intellij does not complain about unresolved magic
// imports in build.sc when in fact they are resolved
- def sbtLibraryNameFromPom(pom : Path) : String = {
+ def sbtLibraryNameFromPom(pom : os.Path) : String = {
val xml = scala.xml.XML.loadFile(pom.toIO)
val groupId = (xml \ "groupId").text
@@ -206,12 +205,12 @@ object GenIdeaImpl {
pathToLibName(path)
}
- def resolvedLibraries(resolved : Seq[Path]) : Seq[ResolvedLibrary] = resolved
+ def resolvedLibraries(resolved : Seq[os.Path]) : Seq[ResolvedLibrary] = resolved
.map(toResolvedJar)
.collect { case Some(r) => r}
val compilerSettings = resolved
- .foldLeft(Map[(Loose.Agg[Path], Seq[String]), Vector[JavaModule]]()) {
+ .foldLeft(Map[(Loose.Agg[os.Path], Seq[String]), Vector[JavaModule]]()) {
(r, q) =>
val key = (q._4, q._5)
r + (key -> (r.getOrElse(key, Vector()) :+ q._3))
@@ -221,10 +220,10 @@ object GenIdeaImpl {
resolvedLibraries(buildLibraryPaths ++ buildDepsPaths).toSet
val fixedFiles = Seq(
- Tuple2(".idea"/"misc.xml", miscXmlTemplate(jdkInfo)),
- Tuple2(".idea"/"scala_settings.xml", scalaSettingsTemplate()),
+ Tuple2(os.rel/".idea"/"misc.xml", miscXmlTemplate(jdkInfo)),
+ Tuple2(os.rel/".idea"/"scala_settings.xml", scalaSettingsTemplate()),
Tuple2(
- ".idea"/"modules.xml",
+ os.rel/".idea"/"modules.xml",
allModulesXmlTemplate(
modules
.filter(!_._2.skipIdea)
@@ -232,14 +231,14 @@ object GenIdeaImpl {
)
),
Tuple2(
- ".idea_modules"/"mill-build.iml",
+ os.rel/".idea_modules"/"mill-build.iml",
rootXmlTemplate(
for(lib <- allBuildLibraries)
yield libraryName(lib)
)
),
Tuple2(
- ".idea"/"scala_compiler.xml",
+ os.rel/".idea"/"scala_compiler.xml",
scalaCompilerTemplate(compilerSettings)
)
)
@@ -252,7 +251,7 @@ object GenIdeaImpl {
case CoursierResolved(_, _, s) => s.map(p => "jar://" + p + "!/")
case OtherResolved(_) => None
}
- Tuple2(".idea"/'libraries/s"$name.xml", libraryXmlTemplate(name, url, sources))
+ Tuple2(os.rel/".idea"/'libraries/s"$name.xml", libraryXmlTemplate(name, url, sources))
}
val moduleFiles = resolved.map{ case (path, resolvedDeps, mod, _, _) =>
@@ -293,7 +292,7 @@ object GenIdeaImpl {
Strict.Agg.from(mod.moduleDeps.map{ m => moduleName(moduleLabels(m))}.distinct),
isTest
)
- Tuple2(".idea_modules"/s"${moduleName(path)}.iml", elem)
+ Tuple2(os.rel/".idea_modules"/s"${moduleName(path)}.iml", elem)
}
fixedFiles ++ libraries ++ moduleFiles
@@ -306,8 +305,8 @@ object GenIdeaImpl {
}
}
- def relify(p: Path) = {
- val r = p.relativeTo(pwd/".idea_modules")
+ def relify(p: os.Path) = {
+ val r = p.relativeTo(os.pwd/".idea_modules")
(Seq.fill(r.ups)("..") ++ r.segments).mkString("/")
}
@@ -387,13 +386,13 @@ object GenIdeaImpl {
</library>
</component>
}
- def moduleXmlTemplate(basePath: Path,
+ def moduleXmlTemplate(basePath: os.Path,
scalaVersionOpt: Option[String],
- resourcePaths: Strict.Agg[Path],
- normalSourcePaths: Strict.Agg[Path],
- generatedSourcePaths: Strict.Agg[Path],
- compileOutputPath: Path,
- generatedSourceOutputPath: Path,
+ resourcePaths: Strict.Agg[os.Path],
+ normalSourcePaths: Strict.Agg[os.Path],
+ generatedSourcePaths: Strict.Agg[os.Path],
+ compileOutputPath: os.Path,
+ generatedSourceOutputPath: os.Path,
libNames: Strict.Agg[String],
depNames: Strict.Agg[String],
isTest: Boolean
@@ -447,7 +446,7 @@ object GenIdeaImpl {
</component>
</module>
}
- def scalaCompilerTemplate(settings: Map[(Loose.Agg[Path], Seq[String]), Seq[JavaModule]]) = {
+ def scalaCompilerTemplate(settings: Map[(Loose.Agg[os.Path], Seq[String]), Seq[JavaModule]]) = {
<project version="4">
<component name="ScalaCompilerConfiguration">
diff --git a/scalalib/src/mill/scalalib/JavaModule.scala b/scalalib/src/mill/scalalib/JavaModule.scala
index 111cfdb2..387011ec 100644
--- a/scalalib/src/mill/scalalib/JavaModule.scala
+++ b/scalalib/src/mill/scalalib/JavaModule.scala
@@ -1,8 +1,6 @@
package mill
package scalalib
-
-import ammonite.ops._
import coursier.Repository
import mill.define.Task
import mill.define.TaskModule
@@ -199,12 +197,12 @@ trait JavaModule extends mill.Module with TaskModule { outer =>
* All individual source files fed into the compiler
*/
def allSourceFiles = T{
- def isHiddenFile(path: Path) = path.segments.last.startsWith(".")
+ def isHiddenFile(path: os.Path) = path.last.startsWith(".")
for {
root <- allSources()
- if exists(root.path)
- path <- (if (root.path.isDir) ls.rec(root.path) else Seq(root.path))
- if path.isFile && ((path.ext == "scala" || path.ext == "java") && !isHiddenFile(path))
+ if os.exists(root.path)
+ path <- (if (os.isDir(root.path)) os.walk(root.path) else Seq(root.path))
+ if os.isFile(path) && ((path.ext == "scala" || path.ext == "java") && !isHiddenFile(path))
} yield PathRef(path)
}
@@ -293,7 +291,7 @@ trait JavaModule extends mill.Module with TaskModule { outer =>
*/
def jar = T{
createJar(
- localClasspath().map(_.path).filter(exists),
+ localClasspath().map(_.path).filter(os.exists),
mainClass()
)
}
@@ -306,13 +304,13 @@ trait JavaModule extends mill.Module with TaskModule { outer =>
val outDir = T.ctx().dest
val javadocDir = outDir / 'javadoc
- mkdir(javadocDir)
+ os.makeDir.all(javadocDir)
val files = for{
ref <- allSources()
- if exists(ref.path)
- p <- (if (ref.path.isDir) ls.rec(ref.path) else Seq(ref.path))
- if p.isFile && (p.ext == "java")
+ if os.exists(ref.path)
+ p <- (if (os.isDir(ref.path)) os.walk(ref.path) else Seq(ref.path))
+ if os.isFile(p) && (p.ext == "java")
} yield p.toNIO.toString
val options = Seq("-d", javadocDir.toNIO.toString)
@@ -340,7 +338,7 @@ trait JavaModule extends mill.Module with TaskModule { outer =>
* The source jar, containing only source code for publishing to Maven Central
*/
def sourceJar = T {
- createJar((allSources() ++ resources()).map(_.path).filter(exists))
+ createJar((allSources() ++ resources()).map(_.path).filter(os.exists))
}
/**
@@ -409,12 +407,12 @@ trait JavaModule extends mill.Module with TaskModule { outer =>
forkEnv(),
args,
workingDir = forkWorkingDir()
- )) catch { case e: InteractiveShelloutException =>
+ )) catch { case e: Exception =>
Result.Failure("subprocess failed")
}
}
- private[this] def backgroundSetup(dest: Path) = {
+ private[this] def backgroundSetup(dest: os.Path) = {
val token = java.util.UUID.randomUUID().toString
val procId = dest / ".mill-background-process-id"
val procTombstone = dest / ".mill-background-process-tombstone"
@@ -432,9 +430,9 @@ trait JavaModule extends mill.Module with TaskModule { outer =>
// killed via some other means, and continue anyway.
val start = System.currentTimeMillis()
while({
- if (exists(procTombstone)) {
+ if (os.exists(procTombstone)) {
Thread.sleep(10)
- rm(procTombstone)
+ os.remove.all(procTombstone)
true
} else {
Thread.sleep(10)
@@ -442,8 +440,8 @@ trait JavaModule extends mill.Module with TaskModule { outer =>
}
})()
- write(procId, token)
- write(procTombstone, token)
+ os.write(procId, token)
+ os.write(procTombstone, token)
(procId, procTombstone, token)
}
@@ -468,7 +466,7 @@ trait JavaModule extends mill.Module with TaskModule { outer =>
Seq(procId.toString, procTombstone.toString, token, finalMainClass()) ++ args,
workingDir = forkWorkingDir(),
background = true
- )) catch { case e: InteractiveShelloutException =>
+ )) catch { case e: Exception =>
Result.Failure("subprocess failed")
}
}
@@ -486,7 +484,7 @@ trait JavaModule extends mill.Module with TaskModule { outer =>
Seq(procId.toString, procTombstone.toString, token, mainClass) ++ args,
workingDir = forkWorkingDir(),
background = true
- )) catch { case e: InteractiveShelloutException =>
+ )) catch { case e: Exception =>
Result.Failure("subprocess failed")
}
}
@@ -513,7 +511,7 @@ trait JavaModule extends mill.Module with TaskModule { outer =>
forkEnv(),
args,
workingDir = forkWorkingDir()
- )) catch { case e: InteractiveShelloutException =>
+ )) catch { case e: Exception =>
Result.Failure("subprocess failed")
}
}
@@ -524,7 +522,7 @@ trait JavaModule extends mill.Module with TaskModule { outer =>
def artifactId: T[String] = artifactName()
- def intellijModulePath: Path = millSourcePath
+ def intellijModulePath: os.Path = millSourcePath
def forkWorkingDir = T{ ammonite.ops.pwd }
diff --git a/scalalib/src/mill/scalalib/Lib.scala b/scalalib/src/mill/scalalib/Lib.scala
index 17eeba3e..80723637 100644
--- a/scalalib/src/mill/scalalib/Lib.scala
+++ b/scalalib/src/mill/scalalib/Lib.scala
@@ -7,7 +7,6 @@ import java.lang.reflect.Modifier
import java.util.zip.ZipInputStream
import javax.tools.ToolProvider
-import ammonite.ops._
import ammonite.util.Util
import coursier.{Cache, Dependency, Fetch, Repository, Resolution}
import Dep.isDotty
@@ -23,8 +22,8 @@ object CompilationResult {
implicit val jsonFormatter: upickle.default.ReadWriter[CompilationResult] = upickle.default.macroRW
}
-// analysisFile is represented by Path, so we won't break caches after file changes
-case class CompilationResult(analysisFile: Path, classes: PathRef)
+// analysisFile is represented by os.Path, so we won't break caches after file changes
+case class CompilationResult(analysisFile: os.Path, classes: PathRef)
object Lib{
private val ReleaseVersion = raw"""(\d+)\.(\d+)\.(\d+)""".r
@@ -40,7 +39,7 @@ object Lib{
}
}
- def grepJar(classPath: Agg[Path], name: String, version: String, sources: Boolean = false) = {
+ def grepJar(classPath: Agg[os.Path], name: String, version: String, sources: Boolean = false) = {
val suffix = if (sources) "-sources" else ""
val mavenStylePath = s"$name-$version$suffix.jar"
val ivyStylePath = {
@@ -111,22 +110,22 @@ object Lib{
ivy"$scalaOrganization:scala-library:$scalaVersion".forceVersion()
)
- def listClassFiles(base: Path): Iterator[String] = {
- if (base.isDir) ls.rec(base).toIterator.filter(_.ext == "class").map(_.relativeTo(base).toString)
+ def listClassFiles(base: os.Path): Iterator[String] = {
+ if (os.isDir(base)) os.walk(base).toIterator.filter(_.ext == "class").map(_.relativeTo(base).toString)
else {
val zip = new ZipInputStream(new FileInputStream(base.toIO))
Iterator.continually(zip.getNextEntry).takeWhile(_ != null).map(_.getName).filter(_.endsWith(".class"))
}
}
- def discoverTests(cl: ClassLoader, framework: Framework, classpath: Agg[Path]) = {
+ def discoverTests(cl: ClassLoader, framework: Framework, classpath: Agg[os.Path]) = {
val fingerprints = framework.fingerprints()
val testClasses = classpath.flatMap { base =>
// Don't blow up if there are no classfiles representing
// the tests to run Instead just don't run anything
- if (!exists(base)) Nil
+ if (!os.exists(base)) Nil
else listClassFiles(base).flatMap { path =>
val cls = cl.loadClass(path.stripSuffix(".class").replace('/', '.'))
val publicConstructorCount =
diff --git a/scalalib/src/mill/scalalib/MiscModule.scala b/scalalib/src/mill/scalalib/MiscModule.scala
index 02a6ebf9..c6449d6e 100644
--- a/scalalib/src/mill/scalalib/MiscModule.scala
+++ b/scalalib/src/mill/scalalib/MiscModule.scala
@@ -1,13 +1,12 @@
package mill
package scalalib
-import ammonite.ops.{Path, RelPath}
import mill.define.Cross.Resolver
import mill.define.{Cross, Task}
import mill.eval.{PathRef, Result}
import mill.util.Loose.Agg
object CrossModuleBase{
- def scalaVersionPaths(scalaVersion: String, f: String => Path) = {
+ def scalaVersionPaths(scalaVersion: String, f: String => os.Path) = {
for(segments <- scalaVersion.split('.').inits.filter(_.nonEmpty))
yield PathRef(f(segments.mkString(".")))
}
diff --git a/scalalib/src/mill/scalalib/PublishModule.scala b/scalalib/src/mill/scalalib/PublishModule.scala
index 5c567452..a3d0856f 100644
--- a/scalalib/src/mill/scalalib/PublishModule.scala
+++ b/scalalib/src/mill/scalalib/PublishModule.scala
@@ -1,7 +1,6 @@
package mill
package scalalib
-import ammonite.ops._
import mill.define.{ExternalModule, Task}
import mill.eval.PathRef
import mill.scalalib.publish.{Artifact, SonatypePublisher}
@@ -29,14 +28,14 @@ trait PublishModule extends JavaModule { outer =>
def pom = T {
val pom = Pom(artifactMetadata(), publishXmlDeps(), artifactId(), pomSettings())
val pomPath = T.ctx().dest / s"${artifactId()}-${publishVersion()}.pom"
- write.over(pomPath, pom)
+ os.write.over(pomPath, pom)
PathRef(pomPath)
}
def ivy = T {
val ivy = Ivy(artifactMetadata(), publishXmlDeps())
val ivyPath = T.ctx().dest / "ivy.xml"
- write.over(ivyPath, ivy)
+ os.write.over(ivyPath, ivy)
PathRef(ivyPath)
}
@@ -103,7 +102,7 @@ object PublishModule extends ExternalModule {
sonatypeSnapshotUri: String = "https://oss.sonatype.org/content/repositories/snapshots",
signed: Boolean = true) = T.command {
- val x: Seq[(Seq[(Path, String)], Artifact)] = Task.sequence(publishArtifacts.value)().map{
+ val x: Seq[(Seq[(os.Path, String)], Artifact)] = Task.sequence(publishArtifacts.value)().map{
case PublishModule.PublishData(a, s) => (s.map{case (p, f) => (p.path, f)}, a)
}
new SonatypePublisher(
diff --git a/scalalib/src/mill/scalalib/ScalaModule.scala b/scalalib/src/mill/scalalib/ScalaModule.scala
index 3c058013..80caf6a9 100644
--- a/scalalib/src/mill/scalalib/ScalaModule.scala
+++ b/scalalib/src/mill/scalalib/ScalaModule.scala
@@ -1,7 +1,6 @@
package mill
package scalalib
-import ammonite.ops._
import coursier.Repository
import mill.define.{Target, Task, TaskModule}
import mill.eval.{PathRef, Result}
@@ -171,7 +170,7 @@ trait ScalaModule extends JavaModule { outer =>
val outDir = T.ctx().dest
val javadocDir = outDir / 'javadoc
- mkdir(javadocDir)
+ os.makeDir.all(javadocDir)
val files = allSourceFiles().map(_.path.toString)
@@ -215,7 +214,7 @@ trait ScalaModule extends JavaModule { outer =>
"scala.tools.nsc.MainGenericRunner",
classPath = runClasspath().map(_.path) ++ scalaCompilerClasspath().map(_.path),
mainArgs = Seq("-usejavacp"),
- workingDir = pwd
+ workingDir = os.pwd
)
Result.Success()
}
@@ -246,7 +245,7 @@ trait ScalaModule extends JavaModule { outer =>
mainClass = "ammonite.Main",
classPath = ammoniteReplClasspath().map(_.path),
mainArgs = replOptions,
- workingDir = pwd
+ workingDir = os.pwd
)
Result.Success()
}
diff --git a/scalalib/src/mill/scalalib/TestRunner.scala b/scalalib/src/mill/scalalib/TestRunner.scala
index 0b9c897f..42e65d63 100644
--- a/scalalib/src/mill/scalalib/TestRunner.scala
+++ b/scalalib/src/mill/scalalib/TestRunner.scala
@@ -1,5 +1,4 @@
package mill.scalalib
-import ammonite.ops.Path
import ammonite.util.Colors
import mill.Agg
import mill.modules.Jvm
@@ -40,12 +39,12 @@ object TestRunner {
System.in,
debugEnabled = false
)
- val home = Path(homeStr)
+ val home = os.Path(homeStr)
}
val result = runTests(
frameworkInstances = TestRunner.frameworks(frameworks),
- entireClasspath = Agg.from(classpath.map(Path(_))),
- testClassfilePath = Agg(Path(testCp)),
+ entireClasspath = Agg.from(classpath.map(os.Path(_))),
+ testClassfilePath = Agg(os.Path(testCp)),
args = arguments
)(ctx)
@@ -53,7 +52,7 @@ object TestRunner {
// dirtied the thread-interrupted flag and forgot to clean up. Otherwise
// that flag causes writing the results to disk to fail
Thread.interrupted()
- ammonite.ops.write(Path(outputPath), upickle.default.write(result))
+ ammonite.ops.write(os.Path(outputPath), upickle.default.write(result))
}catch{case e: Throwable =>
println(e)
e.printStackTrace()
@@ -65,8 +64,8 @@ object TestRunner {
}
def runTests(frameworkInstances: ClassLoader => Seq[sbt.testing.Framework],
- entireClasspath: Agg[Path],
- testClassfilePath: Agg[Path],
+ entireClasspath: Agg[os.Path],
+ testClassfilePath: Agg[os.Path],
args: Seq[String])
(implicit ctx: Ctx.Log with Ctx.Home): (String, Seq[mill.scalalib.TestRunner.Result]) = {
//Leave the context class loader set and open so that shutdown hooks can access it
diff --git a/scalalib/src/mill/scalalib/ZincWorkerApi.scala b/scalalib/src/mill/scalalib/ZincWorkerApi.scala
index 8e95eb29..dbcaa6da 100644
--- a/scalalib/src/mill/scalalib/ZincWorkerApi.scala
+++ b/scalalib/src/mill/scalalib/ZincWorkerApi.scala
@@ -1,7 +1,5 @@
package mill.scalalib
-
-import ammonite.ops.Path
import coursier.Cache
import coursier.maven.MavenRepository
import mill.Agg
@@ -60,30 +58,30 @@ trait ZincWorkerModule extends mill.Module{
trait ZincWorkerApi {
/** Compile a Java-only project */
def compileJava(upstreamCompileOutput: Seq[CompilationResult],
- sources: Agg[Path],
- compileClasspath: Agg[Path],
+ sources: Agg[os.Path],
+ compileClasspath: Agg[os.Path],
javacOptions: Seq[String])
(implicit ctx: mill.util.Ctx): mill.eval.Result[CompilationResult]
/** Compile a mixed Scala/Java or Scala-only project */
def compileMixed(upstreamCompileOutput: Seq[CompilationResult],
- sources: Agg[Path],
- compileClasspath: Agg[Path],
+ sources: Agg[os.Path],
+ compileClasspath: Agg[os.Path],
javacOptions: Seq[String],
scalaVersion: String,
scalacOptions: Seq[String],
- compilerBridgeSources: Path,
- compilerClasspath: Agg[Path],
- scalacPluginClasspath: Agg[Path])
+ compilerBridgeSources: os.Path,
+ compilerClasspath: Agg[os.Path],
+ scalacPluginClasspath: Agg[os.Path])
(implicit ctx: mill.util.Ctx): mill.eval.Result[CompilationResult]
def discoverMainClasses(compilationResult: CompilationResult)
(implicit ctx: mill.util.Ctx): Seq[String]
def docJar(scalaVersion: String,
- compilerBridgeSources: Path,
- compilerClasspath: Agg[Path],
- scalacPluginClasspath: Agg[Path],
+ compilerBridgeSources: os.Path,
+ compilerClasspath: Agg[os.Path],
+ scalacPluginClasspath: Agg[os.Path],
args: Seq[String])
(implicit ctx: mill.util.Ctx): Boolean
}
diff --git a/scalalib/src/mill/scalalib/dependency/versions/VersionsFinder.scala b/scalalib/src/mill/scalalib/dependency/versions/VersionsFinder.scala
index abe6e012..b1033688 100644
--- a/scalalib/src/mill/scalalib/dependency/versions/VersionsFinder.scala
+++ b/scalalib/src/mill/scalalib/dependency/versions/VersionsFinder.scala
@@ -1,6 +1,5 @@
package mill.scalalib.dependency.versions
-import ammonite.ops.pwd
import mill.define.{BaseModule, Task}
import mill.eval.Evaluator
import mill.scalalib.dependency.metadata.MetadataLoaderFactory
@@ -13,7 +12,7 @@ private[dependency] object VersionsFinder {
def findVersions(ctx: Log with Home,
rootModule: BaseModule): Seq[ModuleDependenciesVersions] = {
val evaluator =
- new Evaluator(ctx.home, pwd / 'out, pwd / 'out, rootModule, ctx.log)
+ new Evaluator(ctx.home, os.pwd / 'out, os.pwd / 'out, rootModule, ctx.log)
val javaModules = rootModule.millInternal.modules.collect {
case javaModule: JavaModule => javaModule
diff --git a/scalalib/src/mill/scalalib/publish/LocalPublisher.scala b/scalalib/src/mill/scalalib/publish/LocalPublisher.scala
index a8a703fc..d9839831 100644
--- a/scalalib/src/mill/scalalib/publish/LocalPublisher.scala
+++ b/scalalib/src/mill/scalalib/publish/LocalPublisher.scala
@@ -1,16 +1,15 @@
package mill.scalalib.publish
-import ammonite.ops._
object LocalPublisher {
- private val root: Path = home / ".ivy2" / "local"
+ private val root: os.Path = os.home / ".ivy2" / "local"
- def publish(jar: Path,
- sourcesJar: Path,
- docJar: Path,
- pom: Path,
- ivy: Path,
+ def publish(jar: os.Path,
+ sourcesJar: os.Path,
+ docJar: os.Path,
+ pom: os.Path,
+ ivy: os.Path,
artifact: Artifact): Unit = {
val releaseDir = root / artifact.group / artifact.id / artifact.version
writeFiles(
@@ -22,11 +21,11 @@ object LocalPublisher {
)
}
- private def writeFiles(fromTo: (Path, Path)*): Unit = {
+ private def writeFiles(fromTo: (os.Path, os.Path)*): Unit = {
fromTo.foreach {
case (from, to) =>
- mkdir(to / up)
- cp.over(from, to)
+ os.makeDir.all(to / os.up)
+ os.copy.over(from, to)
}
}
diff --git a/scalalib/src/mill/scalalib/publish/SonatypePublisher.scala b/scalalib/src/mill/scalalib/publish/SonatypePublisher.scala
index 47ec8dbf..5e596618 100644
--- a/scalalib/src/mill/scalalib/publish/SonatypePublisher.scala
+++ b/scalalib/src/mill/scalalib/publish/SonatypePublisher.scala
@@ -3,7 +3,6 @@ package mill.scalalib.publish
import java.math.BigInteger
import java.security.MessageDigest
-import ammonite.ops._
import mill.util.Logger
import scalaj.http.HttpResponse
@@ -17,10 +16,10 @@ class SonatypePublisher(uri: String,
private val api = new SonatypeHttpApi(uri, credentials)
- def publish(fileMapping: Seq[(Path, String)], artifact: Artifact, release: Boolean): Unit = {
+ def publish(fileMapping: Seq[(os.Path, String)], artifact: Artifact, release: Boolean): Unit = {
publishAll(release, fileMapping -> artifact)
}
- def publishAll(release: Boolean, artifacts: (Seq[(Path, String)], Artifact)*): Unit = {
+ def publishAll(release: Boolean, artifacts: (Seq[(os.Path, String)], Artifact)*): Unit = {
val mappings = for ((fileMapping0, artifact) <- artifacts) yield {
val publishPath = Seq(
@@ -36,7 +35,7 @@ class SonatypePublisher(uri: String,
artifact -> (fileMapping ++ signedArtifacts).flatMap {
case (file, name) =>
- val content = read.bytes(file)
+ val content = os.read.bytes(file)
Seq(
name -> content,
@@ -136,16 +135,17 @@ class SonatypePublisher(uri: String,
}
// http://central.sonatype.org/pages/working-with-pgp-signatures.html#signing-a-file
- private def poorMansSign(file: Path, maybePassphrase: Option[String]): Path = {
+ private def poorMansSign(file: os.Path, maybePassphrase: Option[String]): os.Path = {
val fileName = file.toString
- import ammonite.ops.ImplicitWd._
maybePassphrase match {
case Some(passphrase) =>
- %("gpg", "--passphrase", passphrase, "--batch", "--yes", "-a", "-b", fileName)
+ os.proc("gpg", "--passphrase", passphrase, "--batch", "--yes", "-a", "-b", fileName)
+ .call(stdin = os.Inherit, stdout = os.Inherit, stderr = os.Inherit)
case None =>
- %("gpg", "--batch", "--yes", "-a", "-b", fileName)
+ os.proc("gpg", "--batch", "--yes", "-a", "-b", fileName)
+ .call(stdin = os.Inherit, stdout = os.Inherit, stderr = os.Inherit)
}
- Path(fileName + ".asc")
+ os.Path(fileName + ".asc")
}
private def md5hex(bytes: Array[Byte]): Array[Byte] =
diff --git a/scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala b/scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala
index 74f64e28..6a81d975 100644
--- a/scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala
+++ b/scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala
@@ -1,6 +1,5 @@
package mill.scalalib.scalafmt
-import ammonite.ops.{exists, ls, pwd}
import mill._
import mill.define._
import mill.scalalib._
@@ -19,7 +18,7 @@ trait ScalafmtModule extends JavaModule {
def scalafmtVersion: T[String] = "1.5.1"
- def scalafmtConfig: Sources = T.sources(pwd / ".scalafmt.conf")
+ def scalafmtConfig: Sources = T.sources(os.pwd / ".scalafmt.conf")
def scalafmtDeps: T[Agg[PathRef]] = T {
Lib.resolveDependencies(
@@ -31,8 +30,8 @@ trait ScalafmtModule extends JavaModule {
protected def filesToFormat(sources: Seq[PathRef]) = {
for {
- pathRef <- sources if exists(pathRef.path)
- file <- ls.rec(pathRef.path) if file.isFile && file.ext == "scala"
+ pathRef <- sources if os.exists(pathRef.path)
+ file <- os.walk(pathRef.path) if os.isFile(file) && file.ext == "scala"
} yield PathRef(file)
}
diff --git a/scalalib/src/mill/scalalib/scalafmt/ScalafmtWorker.scala b/scalalib/src/mill/scalalib/scalafmt/ScalafmtWorker.scala
index d9921e9d..41fad45b 100644
--- a/scalalib/src/mill/scalalib/scalafmt/ScalafmtWorker.scala
+++ b/scalalib/src/mill/scalalib/scalafmt/ScalafmtWorker.scala
@@ -1,6 +1,5 @@
package mill.scalalib.scalafmt
-import ammonite.ops.{Path, exists}
import mill._
import mill.define.{Discover, ExternalModule, Worker}
import mill.modules.Jvm
@@ -15,12 +14,12 @@ object ScalafmtWorkerModule extends ExternalModule {
}
private[scalafmt] class ScalafmtWorker {
- private val reformatted: mutable.Map[Path, Int] = mutable.Map.empty
+ private val reformatted: mutable.Map[os.Path, Int] = mutable.Map.empty
private var configSig: Int = 0
def reformat(input: Seq[PathRef],
scalafmtConfig: PathRef,
- scalafmtClasspath: Agg[Path])(implicit ctx: Ctx): Unit = {
+ scalafmtClasspath: Agg[os.Path])(implicit ctx: Ctx): Unit = {
val toFormat =
if (scalafmtConfig.sig != configSig) input
else
@@ -43,11 +42,11 @@ private[scalafmt] class ScalafmtWorker {
private val cliFlags = Seq("--non-interactive", "--quiet")
- private def reformatAction(toFormat: Seq[Path],
- config: Path,
- classpath: Agg[Path])(implicit ctx: Ctx) = {
+ private def reformatAction(toFormat: Seq[os.Path],
+ config: os.Path,
+ classpath: Agg[os.Path])(implicit ctx: Ctx) = {
val configFlags =
- if (exists(config)) Seq("--config", config.toString) else Seq.empty
+ if (os.exists(config)) Seq("--config", config.toString) else Seq.empty
Jvm.subprocess(
"org.scalafmt.cli.Cli",
classpath,
diff --git a/scalalib/test/src/mill/scalalib/GenIdeaTests.scala b/scalalib/test/src/mill/scalalib/GenIdeaTests.scala
index db70a325..d4a8cabd 100644
--- a/scalalib/test/src/mill/scalalib/GenIdeaTests.scala
+++ b/scalalib/test/src/mill/scalalib/GenIdeaTests.scala
@@ -1,6 +1,5 @@
package mill.scalalib
-import ammonite.ops._
import coursier.Cache
import mill._
import mill.util.{TestEvaluator, TestUtil}
@@ -8,7 +7,7 @@ import utest._
object GenIdeaTests extends TestSuite {
- val millSourcePath = pwd / 'target / 'workspace / "gen-idea"
+ val millSourcePath = os.pwd / 'target / 'workspace / "gen-idea"
trait HelloWorldModule extends scalalib.ScalaModule {
def scalaVersion = "2.12.4"
@@ -31,7 +30,7 @@ object GenIdeaTests extends TestSuite {
HelloWorld,
("JDK_1_8", "1.8 (1)"), fetchMillModules = false)
for((relPath, xml) <- layout){
- write.over(millSourcePath/ "generated"/ relPath, pp.format(xml))
+ os.write.over(millSourcePath/ "generated"/ relPath, pp.format(xml))
}
Seq(
@@ -49,7 +48,7 @@ object GenIdeaTests extends TestSuite {
millSourcePath / "generated" / ".idea" / "misc.xml"
).foreach { case (resource, generated) =>
val resourceString = scala.io.Source.fromResource(resource).getLines().mkString("\n")
- val generatedString = normaliseLibraryPaths(read! generated)
+ val generatedString = normaliseLibraryPaths(os.read(generated))
assert(resourceString == generatedString)
}
diff --git a/scalalib/test/src/mill/scalalib/HelloJavaTests.scala b/scalalib/test/src/mill/scalalib/HelloJavaTests.scala
index 7e044475..ff0de5a6 100644
--- a/scalalib/test/src/mill/scalalib/HelloJavaTests.scala
+++ b/scalalib/test/src/mill/scalalib/HelloJavaTests.scala
@@ -2,8 +2,6 @@ package mill
package scalalib
-import ammonite.ops.{%, %%, cp, ls, mkdir, pwd, rm, up}
-import ammonite.ops.ImplicitWd._
import mill.eval.Result
import mill.util.{TestEvaluator, TestUtil}
import utest._
@@ -27,14 +25,14 @@ object HelloJavaTests extends TestSuite {
object test extends Tests with JUnitTests
}
}
- val resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-java"
+ val resourcePath = os.pwd / 'scalalib / 'test / 'resources / "hello-java"
def init()(implicit tp: TestPath) = {
val eval = new TestEvaluator(HelloJava)
- rm(HelloJava.millSourcePath)
- rm(eval.outPath)
- mkdir(HelloJava.millSourcePath / up)
- cp(resourcePath, HelloJava.millSourcePath)
+ os.remove.all(HelloJava.millSourcePath)
+ os.remove.all(eval.outPath)
+ os.makeDir.all(HelloJava.millSourcePath / os.up)
+ os.copy(resourcePath, HelloJava.millSourcePath)
eval
}
def tests: Tests = Tests {
@@ -49,10 +47,10 @@ object HelloJavaTests extends TestSuite {
res1 == res2,
n1 != 0,
n2 != 0,
- ls.rec(res1.classes.path).exists(_.last == "Core.class"),
- !ls.rec(res1.classes.path).exists(_.last == "Main.class"),
- ls.rec(res3.classes.path).exists(_.last == "Main.class"),
- !ls.rec(res3.classes.path).exists(_.last == "Core.class")
+ os.walk(res1.classes.path).exists(_.last == "Core.class"),
+ !os.walk(res1.classes.path).exists(_.last == "Main.class"),
+ os.walk(res3.classes.path).exists(_.last == "Main.class"),
+ !os.walk(res3.classes.path).exists(_.last == "Core.class")
)
}
'docJar - {
@@ -62,8 +60,8 @@ object HelloJavaTests extends TestSuite {
val Right((ref2, _)) = eval.apply(HelloJava.app.docJar)
assert(
- %%("jar", "tf", ref1.path).out.lines.contains("hello/Core.html"),
- %%("jar", "tf", ref2.path).out.lines.contains("hello/Main.html")
+ os.proc("jar", "tf", ref1.path).call().out.lines.contains("hello/Core.html"),
+ os.proc("jar", "tf", ref2.path).call().out.lines.contains("hello/Main.html")
)
}
'test - {
diff --git a/scalalib/test/src/mill/scalalib/HelloWorldTests.scala b/scalalib/test/src/mill/scalalib/HelloWorldTests.scala
index 1839e275..67c4b433 100644
--- a/scalalib/test/src/mill/scalalib/HelloWorldTests.scala
+++ b/scalalib/test/src/mill/scalalib/HelloWorldTests.scala
@@ -1,8 +1,8 @@
package mill.scalalib
+import java.io.ByteArrayOutputStream
import java.util.jar.JarFile
-import ammonite.ops._
import mill._
import mill.define.Target
import mill.eval.Result.Exception
@@ -265,7 +265,7 @@ object HelloWorldTests extends TestSuite {
}
}
- val resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world"
+ val resourcePath = os.pwd / 'scalalib / 'test / 'resources / "hello-world"
def jarMainClass(jar: JarFile): Option[String] = {
import java.util.jar.Attributes._
@@ -279,10 +279,12 @@ object HelloWorldTests extends TestSuite {
def readFileFromJar(jar: JarFile, name: String): String = {
val is = jar.getInputStream(jar.getEntry(name))
- read(is)
+ val baos = new ByteArrayOutputStream()
+ os.Internals.transfer(is, baos)
+ new String(baos.toByteArray)
}
- def compileClassfiles = Seq[RelPath](
+ def compileClassfiles = Seq[os.RelPath](
"Main.class",
"Main$.class",
"Main0.class",
@@ -292,14 +294,14 @@ object HelloWorldTests extends TestSuite {
"Person$.class"
)
- 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)
}
@@ -371,29 +373,29 @@ object HelloWorldTests extends TestSuite {
// make sure options are passed during ScalaDoc generation
'docJarWithTitle - workspaceTest(
HelloWorldDocTitle,
- resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world"
+ resourcePath = os.pwd / 'scalalib / 'test / 'resources / "hello-world"
){ eval =>
val Right((_, evalCount)) = eval.apply(HelloWorldDocTitle.core.docJar)
assert(
evalCount > 0,
- read(eval.outPath / 'core / 'docJar / 'dest / 'javadoc / "index.html").contains("<span id=\"doc-title\">Hello World")
+ os.read(eval.outPath / 'core / 'docJar / 'dest / 'javadoc / "index.html").contains("<span id=\"doc-title\">Hello World")
)
}
'docJarWithVersion - workspaceTest(
HelloWorldWithDocVersion,
- resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world"
+ resourcePath = os.pwd / 'scalalib / 'test / 'resources / "hello-world"
){ eval =>
// scaladoc generation fails because of "-Xfatal-warnings" flag
val Left(Result.Failure("docJar generation failed", None)) = eval.apply(HelloWorldWithDocVersion.core.docJar)
}
'docJarOnlyVersion - workspaceTest(
HelloWorldOnlyDocVersion,
- resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world"
+ resourcePath = os.pwd / 'scalalib / 'test / 'resources / "hello-world"
){ eval =>
val Right((_, evalCount)) = eval.apply(HelloWorldOnlyDocVersion.core.docJar)
assert(
evalCount > 0,
- read(eval.outPath / 'core / 'docJar / 'dest / 'javadoc / "index.html").contains("<span id=\"doc-version\">1.2.3")
+ os.read(eval.outPath / 'core / 'docJar / 'dest / 'javadoc / "index.html").contains("<span id=\"doc-version\">1.2.3")
)
}
}
@@ -426,13 +428,13 @@ object HelloWorldTests extends TestSuite {
val Right((result, evalCount)) = eval.apply(HelloWorld.core.compile)
val analysisFile = result.analysisFile
- val outputFiles = ls.rec(result.classes.path)
+ val outputFiles = os.walk(result.classes.path)
val expectedClassfiles = compileClassfiles.map(
eval.outPath / 'core / 'compile / 'dest / 'classes / _
)
assert(
result.classes.path == eval.outPath / 'core / 'compile / 'dest / 'classes,
- exists(analysisFile),
+ os.exists(analysisFile),
outputFiles.nonEmpty,
outputFiles.forall(expectedClassfiles.contains),
evalCount > 0
@@ -447,13 +449,13 @@ object HelloWorldTests extends TestSuite {
val Right((_, freshCount)) = eval.apply(HelloWorld.core.compile)
assert(freshCount > 0)
- write.append(HelloWorld.millSourcePath / 'core / 'src / "Main.scala", "\n")
+ os.write.append(HelloWorld.millSourcePath / 'core / 'src / "Main.scala", "\n")
val Right((_, incCompileCount)) = eval.apply(HelloWorld.core.compile)
assert(incCompileCount > 0, incCompileCount < freshCount)
}
'failOnError - workspaceTest(HelloWorld){eval =>
- write.append(HelloWorld.millSourcePath / 'core / 'src / "Main.scala", "val x: ")
+ os.write.append(HelloWorld.millSourcePath / 'core / 'src / "Main.scala", "val x: ")
val Left(Result.Failure("Compilation failed", _)) = eval.apply(HelloWorld.core.compile)
@@ -464,13 +466,13 @@ object HelloWorldTests extends TestSuite {
)
assert(
- ls.rec(paths.dest / 'classes).isEmpty,
- !exists(paths.meta)
+ os.walk(paths.dest / 'classes).isEmpty,
+ !os.exists(paths.meta)
)
// Works when fixed
- write.over(
+ os.write.over(
HelloWorld.millSourcePath / 'core / 'src / "Main.scala",
- read(HelloWorld.millSourcePath / 'core / 'src / "Main.scala").dropRight("val x: ".length)
+ os.read(HelloWorld.millSourcePath / 'core / 'src / "Main.scala").dropRight("val x: ".length)
)
val Right((result, evalCount)) = eval.apply(HelloWorld.core.compile)
@@ -489,8 +491,8 @@ object HelloWorldTests extends TestSuite {
assert(evalCount > 0)
assert(
- exists(runResult),
- read(runResult) == "hello rockjam, your age is: 25"
+ os.exists(runResult),
+ os.read(runResult) == "hello rockjam, your age is: 25"
)
}
'runCross - {
@@ -506,8 +508,8 @@ object HelloWorldTests extends TestSuite {
assert(
- exists(runResult),
- read(runResult) == expectedOut
+ os.exists(runResult),
+ os.read(runResult) == expectedOut
)
}
'v210 - TestUtil.disableInJava9OrAbove(workspaceTest(CrossHelloWorld)(cross(_, "2.10.6", "2.10.6 rox")))
@@ -522,7 +524,7 @@ object HelloWorldTests extends TestSuite {
val Left(Result.Failure("subprocess failed", _)) = eval.apply(HelloWorld.core.runMain("Invalid"))
}
'notRunWhenCompileFailed - workspaceTest(HelloWorld){eval =>
- write.append(HelloWorld.millSourcePath / 'core / 'src / "Main.scala", "val x: ")
+ os.write.append(HelloWorld.millSourcePath / 'core / 'src / "Main.scala", "val x: ")
val Left(Result.Failure("Compilation failed", _)) = eval.apply(HelloWorld.core.runMain("Main"))
@@ -540,13 +542,13 @@ object HelloWorldTests extends TestSuite {
assert(
- exists(runResult),
- read(runResult) == "hello rockjam, your age is: 25"
+ os.exists(runResult),
+ os.read(runResult) == "hello rockjam, your age is: 25"
)
}
'notRunWithoutMainClass - workspaceTest(
HelloWorldWithoutMain,
- pwd / 'scalalib / 'test / 'resources / "hello-world-no-main"
+ os.pwd / 'scalalib / 'test / 'resources / "hello-world-no-main"
){eval =>
val Left(Result.Failure(_, None)) = eval.apply(HelloWorldWithoutMain.core.run())
}
@@ -563,8 +565,8 @@ object HelloWorldTests extends TestSuite {
assert(
- exists(runResult),
- read(runResult) == "hello rockjam, your age is: 25"
+ os.exists(runResult),
+ os.read(runResult) == "hello rockjam, your age is: 25"
)
}
}
@@ -580,8 +582,8 @@ object HelloWorldTests extends TestSuite {
assert(
- exists(runResult),
- read(runResult) == "hello rockjam, your age is: 25"
+ os.exists(runResult),
+ os.read(runResult) == "hello rockjam, your age is: 25"
)
}
'runWithDefaultMain - workspaceTest(HelloWorldDefaultMain){eval =>
@@ -594,13 +596,13 @@ object HelloWorldTests extends TestSuite {
assert(
- exists(runResult),
- read(runResult) == "hello rockjam, your age is: 25"
+ os.exists(runResult),
+ os.read(runResult) == "hello rockjam, your age is: 25"
)
}
'notRunWithoutMainClass - workspaceTest(
HelloWorldWithoutMain,
- pwd / 'scalalib / 'test / 'resources / "hello-world-no-main"
+ os.pwd / 'scalalib / 'test / 'resources / "hello-world-no-main"
){eval =>
val Left(Result.Failure(_, None)) = eval.apply(HelloWorldWithoutMain.core.runLocal())
@@ -612,15 +614,15 @@ object HelloWorldTests extends TestSuite {
val Right((result, evalCount)) = eval.apply(HelloWorldWithMain.core.jar)
assert(
- exists(result.path),
+ os.exists(result.path),
evalCount > 0
)
val jarFile = new JarFile(result.path.toIO)
val entries = jarFile.entries().asScala.map(_.getName).toSet
- val otherFiles = Seq[RelPath](
- "META-INF" / "MANIFEST.MF",
+ val otherFiles = Seq[os.RelPath](
+ os.rel / "META-INF" / "MANIFEST.MF",
"reference.conf"
)
val expectedFiles = compileClassfiles ++ otherFiles
@@ -639,7 +641,7 @@ object HelloWorldTests extends TestSuite {
eval.apply(HelloWorld.core.compile)
val logFile = outPath / 'core / 'compile / 'log
- assert(exists(logFile))
+ assert(os.exists(logFile))
}
}
@@ -647,7 +649,7 @@ object HelloWorldTests extends TestSuite {
'assembly - workspaceTest(HelloWorldWithMain){ eval =>
val Right((result, evalCount)) = eval.apply(HelloWorldWithMain.core.assembly)
assert(
- exists(result.path),
+ os.exists(result.path),
evalCount > 0
)
val jarFile = new JarFile(result.path.toIO)
@@ -687,7 +689,7 @@ object HelloWorldTests extends TestSuite {
)
}
- val helloWorldMultiResourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world-multi"
+ val helloWorldMultiResourcePath = os.pwd / 'scalalib / 'test / 'resources / "hello-world-multi"
def checkAppendMulti[M <: TestUtil.BaseModule](
module: M,
@@ -734,7 +736,7 @@ object HelloWorldTests extends TestSuite {
def checkExclude[M <: TestUtil.BaseModule](module: M,
target: Target[PathRef],
- resourcePath: Path = resourcePath
+ resourcePath: os.Path = resourcePath
) =
workspaceTest(module, resourcePath) { eval =>
val Right((result, _)) = eval.apply(target)
@@ -814,16 +816,16 @@ object HelloWorldTests extends TestSuite {
val Right((result, evalCount)) = eval.apply(HelloWorldWithMain.core.assembly)
assert(
- exists(result.path),
+ os.exists(result.path),
evalCount > 0
)
val runResult = eval.outPath / "hello-mill"
- %%("java", "-jar", result.path, runResult)(wd = eval.outPath)
+ os.proc("java", "-jar", result.path, runResult).call(cwd = eval.outPath)
assert(
- exists(runResult),
- read(runResult) == "hello rockjam, your age is: 25"
+ os.exists(runResult),
+ os.read(runResult) == "hello rockjam, your age is: 25"
)
}
}
@@ -866,7 +868,7 @@ object HelloWorldTests extends TestSuite {
// make sure macros are applied when compiling/running
'runMain - workspaceTest(
HelloWorldMacros,
- resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world-macros"
+ resourcePath = os.pwd / 'scalalib / 'test / 'resources / "hello-world-macros"
){ eval =>
val Right((_, evalCount)) = eval.apply(HelloWorldMacros.core.runMain("Main"))
assert(evalCount > 0)
@@ -874,7 +876,7 @@ object HelloWorldTests extends TestSuite {
// make sure macros are applied when compiling during scaladoc generation
'docJar - workspaceTest(
HelloWorldMacros,
- resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world-macros"
+ resourcePath = os.pwd / 'scalalib / 'test / 'resources / "hello-world-macros"
){ eval =>
val Right((_, evalCount)) = eval.apply(HelloWorldMacros.core.docJar)
assert(evalCount > 0)
@@ -885,7 +887,7 @@ object HelloWorldTests extends TestSuite {
// make sure flags are passed when compiling/running
'runMain - workspaceTest(
HelloWorldFlags,
- resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world-flags"
+ resourcePath = os.pwd / 'scalalib / 'test / 'resources / "hello-world-flags"
){ eval =>
val Right((_, evalCount)) = eval.apply(HelloWorldFlags.core.runMain("Main"))
assert(evalCount > 0)
@@ -893,7 +895,7 @@ object HelloWorldTests extends TestSuite {
// make sure flags are passed during ScalaDoc generation
'docJar - workspaceTest(
HelloWorldFlags,
- resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world-flags"
+ resourcePath = os.pwd / 'scalalib / 'test / 'resources / "hello-world-flags"
){ eval =>
val Right((_, evalCount)) = eval.apply(HelloWorldFlags.core.docJar)
assert(evalCount > 0)
@@ -902,7 +904,7 @@ object HelloWorldTests extends TestSuite {
'scalacheck - workspaceTest(
HelloScalacheck,
- resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-scalacheck"
+ resourcePath = os.pwd / 'scalalib / 'test / 'resources / "hello-scalacheck"
){ eval =>
val Right((res, evalCount)) = eval.apply(HelloScalacheck.foo.test.test())
assert(
@@ -918,7 +920,7 @@ object HelloWorldTests extends TestSuite {
'dotty - workspaceTest(
HelloDotty,
- resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-dotty"
+ resourcePath = os.pwd / 'scalalib / 'test / 'resources / "hello-dotty"
){ eval =>
if (isJavaAtLeast("9")) {
// Skip the test because Dotty does not support Java >= 9 yet
diff --git a/scalalib/test/src/mill/scalalib/scalafmt/ScalafmtTests.scala b/scalalib/test/src/mill/scalalib/scalafmt/ScalafmtTests.scala
index 89d549ff..dcbdb769 100644
--- a/scalalib/test/src/mill/scalalib/scalafmt/ScalafmtTests.scala
+++ b/scalalib/test/src/mill/scalalib/scalafmt/ScalafmtTests.scala
@@ -1,6 +1,5 @@
package mill.scalalib.scalafmt
-import ammonite.ops._
import mill.main.Tasks
import mill.scalalib.ScalaModule
import mill.util.{TestEvaluator, TestUtil}
@@ -20,17 +19,17 @@ object ScalafmtTests extends TestSuite {
}
}
- val resourcePath = pwd / 'scalalib / 'test / 'resources / 'scalafmt
+ val resourcePath = os.pwd / 'scalalib / 'test / 'resources / 'scalafmt
def workspaceTest[T](
m: TestUtil.BaseModule,
- resourcePath: Path = resourcePath)(t: TestEvaluator => T)(
+ 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)
}
@@ -68,7 +67,7 @@ object ScalafmtTests extends TestSuite {
)
// reformat after change
- write.over(cached("Main.scala").path,
+ os.write.over(cached("Main.scala").path,
cached("Main.scala").content + "\n object Foo")
val Right(_) = eval.apply(reformatCommand)
@@ -89,16 +88,16 @@ object ScalafmtTests extends TestSuite {
}
}
- case class FileInfo(content: String, modifyTime: Long, path: Path)
+ case class FileInfo(content: String, modifyTime: Long, path: os.Path)
def getProjectFiles(m: ScalaModule, eval: TestEvaluator) = {
val Right((sources, _)) = eval.apply(m.sources)
val Right((resources, _)) = eval.apply(m.resources)
- val sourcesFiles = sources.flatMap(p => ls.rec(p.path))
- val resourcesFiles = resources.flatMap(p => ls.rec(p.path))
+ val sourcesFiles = sources.flatMap(p => os.walk(p.path))
+ val resourcesFiles = resources.flatMap(p => os.walk(p.path))
(sourcesFiles ++ resourcesFiles).map { p =>
- p.name -> FileInfo(read(p), p.mtime.toMillis, p)
+ p.last -> FileInfo(os.read(p), os.mtime(p), p)
}.toMap
}
diff --git a/scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala b/scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala
index 78595b14..d494760e 100644
--- a/scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala
+++ b/scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala
@@ -3,7 +3,6 @@ package mill.scalalib.worker
import java.io.File
import java.util.Optional
-import ammonite.ops.{Path, exists, ls, mkdir}
import ammonite.util.Colors
import mill.Agg
import mill.eval.PathRef
@@ -50,9 +49,9 @@ class ZincWorkerImpl(ctx0: mill.util.Ctx,
@volatile var mixedCompilersCache = Option.empty[(Long, Compilers)]
def docJar(scalaVersion: String,
- compilerBridgeSources: Path,
- compilerClasspath: Agg[Path],
- scalacPluginClasspath: Agg[Path],
+ compilerBridgeSources: os.Path,
+ compilerClasspath: Agg[os.Path],
+ scalacPluginClasspath: Agg[os.Path],
args: Seq[String])
(implicit ctx: mill.util.Ctx): Boolean = {
val compilers: Compilers = prepareCompilers(
@@ -69,16 +68,16 @@ class ZincWorkerImpl(ctx0: mill.util.Ctx,
* TODO: Proper invalidation, see #389
*/
def compileZincBridgeIfNeeded(scalaVersion: String,
- sourcesJar: Path,
- compilerJars: Array[File]): Path = {
+ sourcesJar: os.Path,
+ compilerJars: Array[File]): os.Path = {
val workingDir = ctx0.dest / scalaVersion
val compiledDest = workingDir / 'compiled
- if (!exists(workingDir)) {
+ if (!os.exists(workingDir)) {
ctx0.log.info("Compiling compiler interface...")
- mkdir(workingDir)
- mkdir(compiledDest)
+ os.makeDir.all(workingDir)
+ os.makeDir.all(compiledDest)
val sourceFolder = mill.modules.Util.unpackZip(sourcesJar)(workingDir)
val classloader = mill.util.ClassLoader.create(compilerJars.map(_.toURI.toURL), null)(ctx0)
@@ -91,7 +90,7 @@ class ZincWorkerImpl(ctx0: mill.util.Ctx,
val argsArray = Array[String](
"-d", compiledDest.toString,
"-classpath", (compilerJars ++ compilerBridgeClasspath).mkString(File.pathSeparator)
- ) ++ ls.rec(sourceFolder.path).filter(_.ext == "scala").map(_.toString)
+ ) ++ os.walk(sourceFolder.path).filter(_.ext == "scala").map(_.toString)
compilerMain.getMethod("process", classOf[Array[String]])
.invoke(null, argsArray)
@@ -116,8 +115,8 @@ class ZincWorkerImpl(ctx0: mill.util.Ctx,
}
def compileJava(upstreamCompileOutput: Seq[CompilationResult],
- sources: Agg[Path],
- compileClasspath: Agg[Path],
+ sources: Agg[os.Path],
+ compileClasspath: Agg[os.Path],
javacOptions: Seq[String])
(implicit ctx: mill.util.Ctx): mill.eval.Result[CompilationResult] = {
compileInternal(
@@ -131,14 +130,14 @@ class ZincWorkerImpl(ctx0: mill.util.Ctx,
}
def compileMixed(upstreamCompileOutput: Seq[CompilationResult],
- sources: Agg[Path],
- compileClasspath: Agg[Path],
+ sources: Agg[os.Path],
+ compileClasspath: Agg[os.Path],
javacOptions: Seq[String],
scalaVersion: String,
scalacOptions: Seq[String],
- compilerBridgeSources: Path,
- compilerClasspath: Agg[Path],
- scalacPluginClasspath: Agg[Path])
+ compilerBridgeSources: os.Path,
+ compilerClasspath: Agg[os.Path],
+ scalacPluginClasspath: Agg[os.Path])
(implicit ctx: mill.util.Ctx): mill.eval.Result[CompilationResult] = {
val compilers: Compilers = prepareCompilers(
scalaVersion,
@@ -158,9 +157,9 @@ class ZincWorkerImpl(ctx0: mill.util.Ctx,
}
private def prepareCompilers(scalaVersion: String,
- compilerBridgeSources: Path,
- compilerClasspath: Agg[Path],
- scalacPluginClasspath: Agg[Path])
+ compilerBridgeSources: os.Path,
+ compilerClasspath: Agg[os.Path],
+ scalacPluginClasspath: Agg[os.Path])
(implicit ctx: mill.util.Ctx)= {
val combinedCompilerClasspath = compilerClasspath ++ scalacPluginClasspath
val combinedCompilerJars = combinedCompilerClasspath.toArray.map(_.toIO)
@@ -170,11 +169,11 @@ class ZincWorkerImpl(ctx0: mill.util.Ctx,
compilerBridgeSources,
compilerClasspath.toArray.map(_.toIO)
)
- val compilerBridgeSig = compilerBridge.mtime.toMillis
+ val compilerBridgeSig = os.mtime(compilerBridge)
val compilersSig =
compilerBridgeSig +
- combinedCompilerClasspath.map(p => p.toString().hashCode + p.mtime.toMillis).sum
+ combinedCompilerClasspath.map(p => p.toString().hashCode + os.mtime(p)).sum
val compilers = mixedCompilersCache match {
case Some((k, v)) if k == compilersSig => v
@@ -205,13 +204,13 @@ class ZincWorkerImpl(ctx0: mill.util.Ctx,
}
private def compileInternal(upstreamCompileOutput: Seq[CompilationResult],
- sources: Agg[Path],
- compileClasspath: Agg[Path],
+ sources: Agg[os.Path],
+ compileClasspath: Agg[os.Path],
javacOptions: Seq[String],
scalacOptions: Seq[String],
compilers: Compilers)
(implicit ctx: mill.util.Ctx): mill.eval.Result[CompilationResult] = {
- mkdir(ctx.dest)
+ os.makeDir.all(ctx.dest)
val logger = {
val consoleAppender = MainAppender.defaultScreen(ConsoleOut.printStreamOut(
diff --git a/scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala b/scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala
index c8d9abda..d8a282de 100644
--- a/scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala
+++ b/scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala
@@ -3,7 +3,6 @@ package scalanativelib
import java.net.URLClassLoader
-import ammonite.ops.Path
import coursier.Cache
import coursier.maven.MavenRepository
import mill.define.{Target, Task}
@@ -71,7 +70,7 @@ trait ScalaNativeModule extends ScalaModule { outer =>
val workerKey = "MILL_SCALANATIVE_WORKER_" + scalaNativeBinaryVersion().replace('.', '_').replace('-', '_')
val workerPath = sys.props(workerKey)
if (workerPath != null)
- Result.Success(Agg(workerPath.split(',').map(p => PathRef(Path(p), quick = true)): _*))
+ Result.Success(Agg(workerPath.split(',').map(p => PathRef(os.Path(p), quick = true)): _*))
else
Lib.resolveDependencies(
Seq(Cache.ivy2Local, MavenRepository("https://repo1.maven.org/maven2")),
diff --git a/scalanativelib/src/mill/scalanativelib/ScalaNativeWorkerApi.scala b/scalanativelib/src/mill/scalanativelib/ScalaNativeWorkerApi.scala
index 05c3f7d7..be834e89 100644
--- a/scalanativelib/src/mill/scalanativelib/ScalaNativeWorkerApi.scala
+++ b/scalanativelib/src/mill/scalanativelib/ScalaNativeWorkerApi.scala
@@ -3,7 +3,6 @@ package mill.scalanativelib
import java.io.File
import java.net.URLClassLoader
-import ammonite.ops.Path
import mill.define.{Discover, Worker}
import mill.{Agg, T}
import sbt.testing.Framework
@@ -12,8 +11,8 @@ import sbt.testing.Framework
class ScalaNativeWorker {
private var scalaInstanceCache = Option.empty[(Long, ScalaNativeWorkerApi)]
- def impl(toolsClasspath: Agg[Path]): ScalaNativeWorkerApi = {
- val classloaderSig = toolsClasspath.map(p => p.toString().hashCode + p.mtime.toMillis).sum
+ def impl(toolsClasspath: Agg[os.Path]): ScalaNativeWorkerApi = {
+ val classloaderSig = toolsClasspath.map(p => p.toString().hashCode + os.mtime(p)).sum
scalaInstanceCache match {
case Some((sig, bridge)) if sig == classloaderSig => bridge
case _ =>
@@ -44,18 +43,18 @@ class ScalaNativeWorker {
case class NativeConfig(config: Any)
trait ScalaNativeWorkerApi {
- def discoverClang: Path
- def discoverClangPP: Path
- def discoverTarget(clang: Path, workDir: Path): String
+ def discoverClang: os.Path
+ def discoverClangPP: os.Path
+ def discoverTarget(clang: os.Path, workDir: os.Path): String
def discoverCompileOptions: Seq[String]
def discoverLinkingOptions: Seq[String]
- def config(nativeLibJar: Path,
+ def config(nativeLibJar: os.Path,
mainClass: String,
- classpath: Seq[Path],
- nativeWorkdir: Path,
- nativeClang: Path,
- nativeClangPP: Path,
+ classpath: Seq[os.Path],
+ nativeWorkdir: os.Path,
+ nativeClang: os.Path,
+ nativeClangPP: os.Path,
nativeTarget: String,
nativeCompileOptions: Seq[String],
nativeLinkingOptions: Seq[String],
@@ -65,7 +64,7 @@ trait ScalaNativeWorkerApi {
logLevel: NativeLogLevel): NativeConfig
def defaultGarbageCollector: String
- def nativeLink(nativeConfig: NativeConfig, outPath: Path): Path
+ def nativeLink(nativeConfig: NativeConfig, outPath: os.Path): os.Path
def newScalaNativeFrameWork(framework: Framework, id: Int, testBinary: File,
logLevel: NativeLogLevel, envVars: Map[String, String]): Framework
diff --git a/scalanativelib/test/src/mill/scalanativelib/HelloNativeWorldTests.scala b/scalanativelib/test/src/mill/scalanativelib/HelloNativeWorldTests.scala
index 4c67b98f..37fbfc80 100644
--- a/scalanativelib/test/src/mill/scalanativelib/HelloNativeWorldTests.scala
+++ b/scalanativelib/test/src/mill/scalanativelib/HelloNativeWorldTests.scala
@@ -2,7 +2,6 @@ package mill.scalanativelib
import java.util.jar.JarFile
-import ammonite.ops._
import mill._
import mill.define.Discover
import mill.eval.{Evaluator, Result}
@@ -73,7 +72,7 @@ object HelloNativeWorldTests extends TestSuite {
override lazy val millDiscover = Discover[this.type]
}
- val millSourcePath = pwd / 'scalanativelib / 'test / 'resources / "hello-native-world"
+ val millSourcePath = os.pwd / 'scalanativelib / 'test / 'resources / "hello-native-world"
val helloWorldEvaluator = TestEvaluator.static(HelloNativeWorld)
@@ -90,7 +89,7 @@ object HelloNativeWorldTests extends TestSuite {
helloWorldEvaluator(HelloNativeWorld.helloNativeWorld(scalaVersion, scalaNativeVersion, mode).compile)
val outPath = result.classes.path
- val outputFiles = ls.rec(outPath).filter(_.isFile)
+ val outputFiles = os.walk(outPath).filter(os.isFile)
val expectedClassfiles = compileClassfiles(outPath / 'hello)
assert(
outputFiles.toSet == expectedClassfiles,
@@ -185,7 +184,7 @@ object HelloNativeWorldTests extends TestSuite {
helloWorldEvaluator.outPath,
task.ctx.segments
)
- val log = read(paths.log)
+ val log = os.read(paths.log)
assert(
evalCount > 0,
log.contains("Scala Native")
@@ -198,7 +197,7 @@ object HelloNativeWorldTests extends TestSuite {
}
}
- def compileClassfiles(parentDir: Path) = Set(
+ def compileClassfiles(parentDir: os.Path) = Set(
parentDir / "ArgsParser$.class",
parentDir / "ArgsParser$.nir",
parentDir / "ArgsParser.class",
@@ -210,8 +209,8 @@ object HelloNativeWorldTests extends TestSuite {
)
def prepareWorkspace(): Unit = {
- rm(workspacePath)
- mkdir(workspacePath / up)
- cp(millSourcePath, workspacePath)
+ os.remove.all(workspacePath)
+ os.makeDir.all(workspacePath / os.up)
+ os.copy(millSourcePath, workspacePath)
}
}
diff --git a/scalanativelib/worker/0.3/src/mill/scalanativelib/worker/ScalaNativeWorkerImpl.scala b/scalanativelib/worker/0.3/src/mill/scalanativelib/worker/ScalaNativeWorkerImpl.scala
index 7e93fbd4..8c24a39e 100644
--- a/scalanativelib/worker/0.3/src/mill/scalanativelib/worker/ScalaNativeWorkerImpl.scala
+++ b/scalanativelib/worker/0.3/src/mill/scalanativelib/worker/ScalaNativeWorkerImpl.scala
@@ -4,7 +4,6 @@ import java.io.File
import java.lang.System.{err, out}
import scala.scalanative.build.{Build, Config, Discover, GC, Logger, Mode}
-import ammonite.ops.Path
import mill.scalanativelib.{NativeConfig, NativeLogLevel, ReleaseMode}
import sbt.testing.Framework
@@ -19,19 +18,19 @@ class ScalaNativeWorkerImpl extends mill.scalanativelib.ScalaNativeWorkerApi {
warnFn = msg => if (level >= NativeLogLevel.Warn) out.println(msg),
errorFn = msg => if (level >= NativeLogLevel.Error) err.println(msg))
- def discoverClang: Path = Path(Discover.clang())
- def discoverClangPP: Path = Path(Discover.clangpp())
- def discoverTarget(clang: Path, workdir: Path): String = Discover.targetTriple(clang.toNIO, workdir.toNIO)
+ def discoverClang: os.Path = os.Path(Discover.clang())
+ def discoverClangPP: os.Path = os.Path(Discover.clangpp())
+ def discoverTarget(clang: os.Path, workdir: os.Path): String = Discover.targetTriple(clang.toNIO, workdir.toNIO)
def discoverCompileOptions: Seq[String] = Discover.compileOptions()
def discoverLinkingOptions: Seq[String] = Discover.linkingOptions()
def defaultGarbageCollector: String = GC.default.name
- def config(nativeLibJar: Path,
+ def config(nativeLibJar: os.Path,
mainClass: String,
- classpath: Seq[Path],
- nativeWorkdir: Path,
- nativeClang: Path,
- nativeClangPP: Path,
+ classpath: Seq[os.Path],
+ nativeWorkdir: os.Path,
+ nativeClang: os.Path,
+ nativeClangPP: os.Path,
nativeTarget: String,
nativeCompileOptions: Seq[String],
nativeLinkingOptions: Seq[String],
@@ -60,7 +59,7 @@ class ScalaNativeWorkerImpl extends mill.scalanativelib.ScalaNativeWorkerApi {
NativeConfig(config)
}
- def nativeLink(nativeConfig: NativeConfig, outPath: Path): Path = {
+ def nativeLink(nativeConfig: NativeConfig, outPath: os.Path): os.Path = {
val config = nativeConfig.config.asInstanceOf[Config]
Build.build(config, outPath.toNIO)
outPath