diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-11-05 03:00:04 +0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-11-05 21:14:58 +0800 |
commit | bc9dc386625021fec517f2dbf0644ccafe1e32c2 (patch) | |
tree | 12db6817470708c7aa274aa231ef35eb79f2123a /scalalib/worker | |
parent | 8afe79afe33be68f59f89b8410984e508c3e8d08 (diff) | |
download | mill-bc9dc386625021fec517f2dbf0644ccafe1e32c2.tar.gz mill-bc9dc386625021fec517f2dbf0644ccafe1e32c2.tar.bz2 mill-bc9dc386625021fec517f2dbf0644ccafe1e32c2.zip |
WIP migrating over from `ammonite.ops` to `os` module.
__.compile works, haven't run tests yet
Diffstat (limited to 'scalalib/worker')
-rw-r--r-- | scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala | 49 |
1 files changed, 24 insertions, 25 deletions
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( |