diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-02 23:36:35 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-02 23:36:35 -0800 |
commit | 4c76e9668ab9683dad1966bcd6fb5031a81f8460 (patch) | |
tree | 333a31b9f5dc247f94ea7011b108502a0fb1bdf1 /shared.sc | |
parent | 932bc5c53bb380930e04765ae51c5a128f3b35fb (diff) | |
download | mill-4c76e9668ab9683dad1966bcd6fb5031a81f8460.tar.gz mill-4c76e9668ab9683dad1966bcd6fb5031a81f8460.tar.bz2 mill-4c76e9668ab9683dad1966bcd6fb5031a81f8460.zip |
- Renamed `Ctx.FooCtx` => `Ctx.Foo`
- Remove un-used `Evaluator#millSourcePath` parameter
Diffstat (limited to 'shared.sc')
-rw-r--r-- | shared.sc | 35 |
1 files changed, 34 insertions, 1 deletions
@@ -100,6 +100,38 @@ 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) @@ -115,5 +147,6 @@ def generateCoreTestSources(p: Path) = { @main def downloadTestRepo(label: String, commit: String, dest: Path) = { - mill.modules.Util.unpackZip(dest, s"https://github.com/$label/archive/$commit.zip")(dest) + unpackZip(dest, s"https://github.com/$label/archive/$commit.zip") + dest }
\ No newline at end of file |