Skip to content

Commit 2e6a7d0

Browse files
authored
Rebootstrap to pull in os-lib 0.11.0 (#3686)
This lets us get rid of the ad-hoc unpackZip code in Mill's own build. Also moved from scalaj-http to requests
1 parent 017b86a commit 2e6a7d0

File tree

7 files changed

+29
-80
lines changed

7 files changed

+29
-80
lines changed

.config/mill-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.12.0-RC3
1+
0.12.0-RC3-17-b4d4fe

build.mill

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,9 @@ trait BridgeModule extends MillPublishJavaModule with CrossScalaModule {
599599
}
600600

601601
def generatedSources = Task {
602+
602603
compilerBridgeSourceJars().foreach { jar =>
603-
mill.api.IO.unpackZip(jar.path, os.rel)
604+
os.unzip(jar.path, T.dest)
604605
}
605606

606607
Seq(PathRef(T.dest))
@@ -984,19 +985,11 @@ def uploadToGithub(authKey: String) = T.command {
984985

985986
if (releaseTag == label) {
986987
// TODO: check if the tag already exists (e.g. because we created it manually) and do not fail
987-
scalaj.http.Http(
988-
s"https://api.github.com/repos/${Settings.githubOrg}/${Settings.githubRepo}/releases"
988+
requests.post(
989+
s"https://api.github.com/repos/${Settings.githubOrg}/${Settings.githubRepo}/releases",
990+
data = ujson.Obj("tag_name" -> releaseTag, "name" -> releaseTag),
991+
headers = Seq("Authorization" -> ("token " + authKey))
989992
)
990-
.postData(
991-
ujson.write(
992-
ujson.Obj(
993-
"tag_name" -> releaseTag,
994-
"name" -> releaseTag
995-
)
996-
)
997-
)
998-
.header("Authorization", "token " + authKey)
999-
.asString
1000993
}
1001994

1002995
val examples = exampleZips().map(z => (z.path, z.path.last))

ci/shared.mill

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,8 @@
11
package build.ci
22

3-
/**
4-
* Utility code that is shared between our SBT build and our Mill build. SBT
5-
* calls this by shelling out to Ammonite in a subprocess, while Mill loads it
6-
* via import $file
7-
*/
83

9-
import $ivy.`org.scalaj::scalaj-http:2.4.2`
10-
import mainargs.main
114

12-
def unpackZip(zipDest: os.Path, url: String) = {
13-
println(s"Unpacking zip $url into $zipDest")
14-
os.makeDir.all(zipDest)
15-
16-
val bytes =
17-
scalaj.http.Http.apply(url).option(scalaj.http.HttpOptions.followRedirects(true)).asBytes
18-
val byteStream = new java.io.ByteArrayInputStream(bytes.body)
19-
val zipStream = new java.util.zip.ZipInputStream(byteStream)
20-
while ({
21-
zipStream.getNextEntry match {
22-
case null => false
23-
case entry =>
24-
if (!entry.isDirectory) {
25-
val dest = zipDest / os.SubPath(entry.getName)
26-
os.makeDir.all(dest / os.up)
27-
val fileOut = new java.io.FileOutputStream(dest.toString)
28-
val buffer = new Array[Byte](4096)
29-
while ({
30-
zipStream.read(buffer) match {
31-
case -1 => false
32-
case n =>
33-
fileOut.write(buffer, 0, n)
34-
true
35-
}
36-
}) ()
37-
fileOut.close()
38-
}
39-
zipStream.closeEntry()
40-
true
41-
}
42-
}) ()
43-
}
44-
45-
@main
465
def downloadTestRepo(label: String, commit: String, dest: os.Path) = {
47-
unpackZip(dest, s"https://github.com/$label/archive/$commit.zip")
6+
os.unzip.stream(requests.get.stream(s"https://github.com/$label/archive/$commit.zip"), dest)
487
dest
498
}

ci/upload.mill

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package build.ci
2-
import scalaj.http._
3-
import mainargs.main
42

5-
@main
63
def apply(
74
uploadedFile: os.Path,
85
tagName: String,
@@ -12,34 +9,36 @@ def apply(
129
githubRepo: String
1310
): String = {
1411

15-
val response = Http(
16-
s"https://api.github.com/repos/${githubOrg}/${githubRepo}/releases/tags/${tagName}"
12+
val response = requests.get(
13+
s"https://api.github.com/repos/${githubOrg}/${githubRepo}/releases/tags/${tagName}",
14+
headers = Seq(
15+
"Authorization" -> s"token $authKey",
16+
"Accept" -> "application/vnd.github.v3+json"
17+
)
1718
)
18-
.header("Authorization", "token " + authKey)
19-
.header("Accept", "application/vnd.github.v3+json")
20-
.asString
21-
val body = response.body
2219

23-
val parsed = ujson.read(body)
20+
val parsed = ujson.read(response)
2421

25-
println("Response code: " + response.code)
26-
println(body)
22+
println("Response code: " + response.statusCode)
23+
println(response.text())
2724

2825
val snapshotReleaseId = parsed("id").num.toInt
2926

3027
val uploadUrl =
3128
s"https://uploads.github.com/repos/${githubOrg}/${githubRepo}/releases/" +
3229
s"$snapshotReleaseId/assets?name=$uploadName"
3330

34-
val res = Http(uploadUrl)
35-
.header("Content-Type", "application/octet-stream")
36-
.header("Authorization", "token " + authKey)
37-
.timeout(connTimeoutMs = 5000, readTimeoutMs = 60000)
38-
.postData(os.read.bytes(uploadedFile))
39-
.asString
40-
41-
println(res.body)
42-
val longUrl = ujson.read(res.body)("browser_download_url").str
31+
val res = requests.post(
32+
uploadUrl,
33+
headers = Seq(
34+
"Content-Type" -> "application/octet-stream",
35+
"Authorization" -> s"token $authKey"
36+
),
37+
data = os.read.stream(uploadedFile)
38+
)
39+
40+
println(res.text())
41+
val longUrl = ujson.read(res)("browser_download_url").str
4342

4443
println("Long Url " + longUrl)
4544
longUrl

example/kotlinlib/android/1-hello-world/app/src/main/kotlin/com/helloworld/app/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class MainActivity : Activity() {
1414
val textView = TextView(this)
1515

1616
// Set the text to "Hello, World!"
17-
textView.text = "Hello, World!"
17+
textView.text = "Hello, World Kotlin!"
1818

1919
// Set text size
2020
textView.textSize = 32f

integration/invalidation/invalidation/resources/build.mill

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package build
22
import mill._
33
import $packages._
4-
import $ivy.`org.scalaj::scalaj-http:2.4.2`
54

65
def task = Task {
76
build.a.input()

mill-build/build.sc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import mill.scalalib._
44

55
object `package` extends MillBuildRootModule {
66
override def ivyDeps = Agg(
7-
ivy"org.scalaj::scalaj-http:2.4.2",
87
ivy"de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0",
98
ivy"com.github.lolgab::mill-mima::0.1.1",
109
ivy"net.sourceforge.htmlcleaner:htmlcleaner:2.29",

0 commit comments

Comments
 (0)