From 4ca8df817e0993aa5f48a06f536eae2c7a97c756 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Tue, 8 Oct 2024 08:06:44 +0200 Subject: [PATCH 1/2] . --- .config/mill-version | 2 +- build.mill | 19 +++----- ci/shared.mill | 43 +------------------ ci/upload.mill | 41 +++++++++--------- .../kotlin/com/helloworld/app/MainActivity.kt | 2 +- .../invalidation/resources/build.mill | 1 - mill-build/build.sc | 1 - 7 files changed, 29 insertions(+), 80 deletions(-) diff --git a/.config/mill-version b/.config/mill-version index 570985f0344f..a3ca0aa6b156 100644 --- a/.config/mill-version +++ b/.config/mill-version @@ -1 +1 @@ -0.12.0-RC3 +0.12.0-RC3-17-b4d4fe \ No newline at end of file diff --git a/build.mill b/build.mill index 0715d9dc3d67..0e905c8b2688 100644 --- a/build.mill +++ b/build.mill @@ -599,8 +599,9 @@ trait BridgeModule extends MillPublishJavaModule with CrossScalaModule { } def generatedSources = Task { + compilerBridgeSourceJars().foreach { jar => - mill.api.IO.unpackZip(jar.path, os.rel) + os.unzip(jar.path, T.dest) } Seq(PathRef(T.dest)) @@ -984,19 +985,11 @@ def uploadToGithub(authKey: String) = T.command { if (releaseTag == label) { // TODO: check if the tag already exists (e.g. because we created it manually) and do not fail - scalaj.http.Http( - s"https://api.github.com/repos/${Settings.githubOrg}/${Settings.githubRepo}/releases" + requests.post( + s"https://api.github.com/repos/${Settings.githubOrg}/${Settings.githubRepo}/releases", + data = ujson.Obj("tag_name" -> releaseTag, "name" -> releaseTag), + headers = Seq("Authorization" -> ("token " + authKey)) ) - .postData( - ujson.write( - ujson.Obj( - "tag_name" -> releaseTag, - "name" -> releaseTag - ) - ) - ) - .header("Authorization", "token " + authKey) - .asString } val examples = exampleZips().map(z => (z.path, z.path.last)) diff --git a/ci/shared.mill b/ci/shared.mill index 2e5298838eaa..d28af501855e 100644 --- a/ci/shared.mill +++ b/ci/shared.mill @@ -1,49 +1,8 @@ package build.ci -/** - * Utility code that is shared between our SBT build and our Mill build. SBT - * calls this by shelling out to Ammonite in a subprocess, while Mill loads it - * via import $file - */ -import $ivy.`org.scalaj::scalaj-http:2.4.2` -import mainargs.main -def unpackZip(zipDest: os.Path, url: String) = { - println(s"Unpacking zip $url into $zipDest") - os.makeDir.all(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 / os.SubPath(entry.getName) - os.makeDir.all(dest / os.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 downloadTestRepo(label: String, commit: String, dest: os.Path) = { - unpackZip(dest, s"https://github.com/$label/archive/$commit.zip") + os.unzip.stream(requests.get.stream(s"https://github.com/$label/archive/$commit.zip"), dest) dest } diff --git a/ci/upload.mill b/ci/upload.mill index e81ba1caf99c..0ef7ec3ae4ee 100644 --- a/ci/upload.mill +++ b/ci/upload.mill @@ -1,8 +1,5 @@ package build.ci -import scalaj.http._ -import mainargs.main -@main def apply( uploadedFile: os.Path, tagName: String, @@ -12,18 +9,18 @@ def apply( githubRepo: String ): String = { - val response = Http( - s"https://api.github.com/repos/${githubOrg}/${githubRepo}/releases/tags/${tagName}" + val response = requests.get( + s"https://api.github.com/repos/${githubOrg}/${githubRepo}/releases/tags/${tagName}", + headers = Seq( + "Authorization" -> s"token $authKey", + "Accept" -> "application/vnd.github.v3+json" + ) ) - .header("Authorization", "token " + authKey) - .header("Accept", "application/vnd.github.v3+json") - .asString - val body = response.body - val parsed = ujson.read(body) + val parsed = ujson.read(response) - println("Response code: " + response.code) - println(body) + println("Response code: " + response.statusCode) + println(response.text()) val snapshotReleaseId = parsed("id").num.toInt @@ -31,15 +28,17 @@ def apply( s"https://uploads.github.com/repos/${githubOrg}/${githubRepo}/releases/" + s"$snapshotReleaseId/assets?name=$uploadName" - val res = Http(uploadUrl) - .header("Content-Type", "application/octet-stream") - .header("Authorization", "token " + authKey) - .timeout(connTimeoutMs = 5000, readTimeoutMs = 60000) - .postData(os.read.bytes(uploadedFile)) - .asString - - println(res.body) - val longUrl = ujson.read(res.body)("browser_download_url").str + val res = requests.post( + uploadUrl, + headers = Seq( + "Content-Type" -> "application/octet-stream", + "Authorization" -> s"token $authKey" + ), + data = os.read.stream(uploadedFile) + ) + + println(res.text()) + val longUrl = ujson.read(res)("browser_download_url").str println("Long Url " + longUrl) longUrl diff --git a/example/kotlinlib/android/1-hello-world/app/src/main/kotlin/com/helloworld/app/MainActivity.kt b/example/kotlinlib/android/1-hello-world/app/src/main/kotlin/com/helloworld/app/MainActivity.kt index 27d851817317..f7e04a63de9f 100644 --- a/example/kotlinlib/android/1-hello-world/app/src/main/kotlin/com/helloworld/app/MainActivity.kt +++ b/example/kotlinlib/android/1-hello-world/app/src/main/kotlin/com/helloworld/app/MainActivity.kt @@ -14,7 +14,7 @@ class MainActivity : Activity() { val textView = TextView(this) // Set the text to "Hello, World!" - textView.text = "Hello, World!" + textView.text = "Hello, World Kotlin!" // Set text size textView.textSize = 32f diff --git a/integration/invalidation/invalidation/resources/build.mill b/integration/invalidation/invalidation/resources/build.mill index a15f4ae0906f..051d65d5b47e 100644 --- a/integration/invalidation/invalidation/resources/build.mill +++ b/integration/invalidation/invalidation/resources/build.mill @@ -1,7 +1,6 @@ package build import mill._ import $packages._ -import $ivy.`org.scalaj::scalaj-http:2.4.2` def task = Task { build.a.input() diff --git a/mill-build/build.sc b/mill-build/build.sc index 356e9306d2a3..23a803a3e44e 100644 --- a/mill-build/build.sc +++ b/mill-build/build.sc @@ -4,7 +4,6 @@ import mill.scalalib._ object `package` extends MillBuildRootModule { override def ivyDeps = Agg( - ivy"org.scalaj::scalaj-http:2.4.2", ivy"de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0", ivy"com.github.lolgab::mill-mima::0.1.1", ivy"net.sourceforge.htmlcleaner:htmlcleaner:2.29", From 9332f708859843e946491c95687e7484baf6acc0 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Tue, 8 Oct 2024 09:57:30 +0200 Subject: [PATCH 2/2] . --- build.mill | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.mill b/build.mill index 0e905c8b2688..72dd2f4ca10e 100644 --- a/build.mill +++ b/build.mill @@ -149,7 +149,7 @@ object Deps { val junitInterface = ivy"com.github.sbt:junit-interface:0.13.3" val commonsIO = ivy"commons-io:commons-io:2.16.1" val log4j2Core = ivy"org.apache.logging.log4j:log4j-core:2.23.1" - val osLib = ivy"com.lihaoyi::os-lib:0.11.0" + val osLib = ivy"com.lihaoyi::os-lib:0.11.1" val pprint = ivy"com.lihaoyi::pprint:0.9.0" val mainargs = ivy"com.lihaoyi::mainargs:0.7.4" val millModuledefsVersion = "0.11.0"