diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-02 23:07:18 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-02 23:07:18 -0800 |
commit | 208b11c20643914547b9d643d1d4e6101cb17cd1 (patch) | |
tree | 543afb8819bd8d3ec60bb0ae9018ba0413db7ea4 | |
parent | de2016a970b1e4bcd2f618815edc616282f7f20e (diff) | |
download | mill-208b11c20643914547b9d643d1d4e6101cb17cd1.tar.gz mill-208b11c20643914547b9d643d1d4e6101cb17cd1.tar.bz2 mill-208b11c20643914547b9d643d1d4e6101cb17cd1.zip |
automatically create dest directory for targets to use
-rwxr-xr-x | build.sc | 2 | ||||
-rw-r--r-- | core/src/mill/eval/Evaluator.scala | 2 | ||||
-rw-r--r-- | core/src/mill/modules/Jvm.scala | 2 | ||||
-rw-r--r-- | core/src/mill/modules/Util.scala | 4 | ||||
-rw-r--r-- | scalalib/src/mill/scalalib/ScalaModule.scala | 1 | ||||
-rw-r--r-- | shared.sc | 35 |
6 files changed, 3 insertions, 43 deletions
@@ -71,7 +71,6 @@ object core extends MillModule { ) def generatedSources = T { - mkdir(T.ctx().dest) shared.generateCoreSources(T.ctx().dest) Agg(PathRef(T.ctx().dest)) } @@ -79,7 +78,6 @@ object core extends MillModule { val test = new Tests(implicitly) class Tests(ctx0: mill.define.Ctx) extends super.Tests(ctx0){ def generatedSources = T { - mkdir(T.ctx().dest) shared.generateCoreTestSources(T.ctx().dest) Agg(PathRef(T.ctx().dest)) } diff --git a/core/src/mill/eval/Evaluator.scala b/core/src/mill/eval/Evaluator.scala index d8d690ac..0b5d372d 100644 --- a/core/src/mill/eval/Evaluator.scala +++ b/core/src/mill/eval/Evaluator.scala @@ -162,6 +162,8 @@ class Evaluator[T](val outPath: Path, if (labelledNamedTask.task.flushDest) rm(paths.dest) + mkdir(paths.dest) + val (newResults, newEvaluated) = evaluateGroup( group, results, diff --git a/core/src/mill/modules/Jvm.scala b/core/src/mill/modules/Jvm.scala index fc1a1665..a22f0c77 100644 --- a/core/src/mill/modules/Jvm.scala +++ b/core/src/mill/modules/Jvm.scala @@ -164,7 +164,6 @@ object Jvm { (implicit ctx: Ctx.DestCtx): PathRef = { val outputPath = ctx.dest / "out.jar" rm(outputPath) - mkdir(outputPath/up) val seen = mutable.Set.empty[RelPath] seen.add("META-INF" / "MANIFEST.MF") @@ -204,7 +203,6 @@ object Jvm { rm(outputPath) if(inputPaths.nonEmpty) { - mkdir(outputPath/up) val output = new FileOutputStream(outputPath.toIO) diff --git a/core/src/mill/modules/Util.scala b/core/src/mill/modules/Util.scala index 542f58d1..ce1203cf 100644 --- a/core/src/mill/modules/Util.scala +++ b/core/src/mill/modules/Util.scala @@ -7,7 +7,6 @@ import mill.util.Ctx object Util { def download(url: String, dest: RelPath = "download")(implicit ctx: Ctx.DestCtx) = { - ammonite.ops.mkdir(ctx.dest) val out = ctx.dest / dest val website = new java.net.URI(url).toURL @@ -27,8 +26,6 @@ object Util { def downloadUnpackZip(url: String, dest: RelPath = "unpacked") (implicit ctx: Ctx.DestCtx) = { - ctx.dest - mkdir(ctx.dest) val tmpName = if (dest == empty / "tmp.zip") "tmp2.zip" else "tmp.zip" val downloaded = download(url, tmpName) @@ -37,7 +34,6 @@ object Util { def unpackZip(src: Path, dest: RelPath = "unpacked") (implicit ctx: Ctx.DestCtx) = { - mkdir(ctx.dest) val byteStream = read.getInputStream(src) val zipStream = new java.util.zip.ZipInputStream(byteStream) diff --git a/scalalib/src/mill/scalalib/ScalaModule.scala b/scalalib/src/mill/scalalib/ScalaModule.scala index 47309350..32d4b259 100644 --- a/scalalib/src/mill/scalalib/ScalaModule.scala +++ b/scalalib/src/mill/scalalib/ScalaModule.scala @@ -301,7 +301,6 @@ trait TestModule extends ScalaModule with TaskModule { } def testLocal(args: String*) = T.command{ - mkdir(T.ctx().dest) val outputPath = T.ctx().dest/"out.json" mill.scalalib.ScalaWorkerApi.scalaWorker().apply( @@ -100,38 +100,6 @@ def generateApplicativeTest(dir: Path) = { ) } -def unpackZip(zipDest: Path, url: String) = { - println(s"Unpacking zip $url into $zipDest") - mkdir(zipDest) - - val bytes = scalaj.http.Http.apply(url).option(scalaj.http.HttpOptions.followRedirects(true)).asBytes - val byteStream = new java.io.ByteArrayInputStream(bytes.body) - val zipStream = new java.util.zip.ZipInputStream(byteStream) - while({ - zipStream.getNextEntry match{ - case null => false - case entry => - if (!entry.isDirectory) { - val dest = zipDest / RelPath(entry.getName) - mkdir(dest / up) - val fileOut = new java.io.FileOutputStream(dest.toString) - val buffer = new Array[Byte](4096) - while ( { - zipStream.read(buffer) match { - case -1 => false - case n => - fileOut.write(buffer, 0, n) - true - } - }) () - fileOut.close() - } - zipStream.closeEntry() - true - } - })() -} - @main def generateCoreSources(p: Path) = { generateApplyer(p) @@ -147,6 +115,5 @@ def generateCoreTestSources(p: Path) = { @main def downloadTestRepo(label: String, commit: String, dest: Path) = { - unpackZip(dest, s"https://github.com/$label/archive/$commit.zip") - dest + mill.modules.Util.unpackZip(dest, s"https://github.com/$label/archive/$commit.zip")(dest) }
\ No newline at end of file |