summaryrefslogtreecommitdiff
path: root/shared.sc
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-02-02 23:07:18 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2018-02-02 23:07:18 -0800
commit208b11c20643914547b9d643d1d4e6101cb17cd1 (patch)
tree543afb8819bd8d3ec60bb0ae9018ba0413db7ea4 /shared.sc
parentde2016a970b1e4bcd2f618815edc616282f7f20e (diff)
downloadmill-208b11c20643914547b9d643d1d4e6101cb17cd1.tar.gz
mill-208b11c20643914547b9d643d1d4e6101cb17cd1.tar.bz2
mill-208b11c20643914547b9d643d1d4e6101cb17cd1.zip
automatically create dest directory for targets to use
Diffstat (limited to 'shared.sc')
-rw-r--r--shared.sc35
1 files changed, 1 insertions, 34 deletions
diff --git a/shared.sc b/shared.sc
index 10d1e148..20e3b548 100644
--- a/shared.sc
+++ b/shared.sc
@@ -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