summaryrefslogtreecommitdiff
path: root/shared.sc
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-02-02 23:36:35 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2018-02-02 23:36:35 -0800
commit4c76e9668ab9683dad1966bcd6fb5031a81f8460 (patch)
tree333a31b9f5dc247f94ea7011b108502a0fb1bdf1 /shared.sc
parent932bc5c53bb380930e04765ae51c5a128f3b35fb (diff)
downloadmill-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.sc35
1 files changed, 34 insertions, 1 deletions
diff --git a/shared.sc b/shared.sc
index 20e3b548..10d1e148 100644
--- a/shared.sc
+++ b/shared.sc
@@ -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