summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-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
8 files changed, 64 insertions, 72 deletions
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 / _
)