Skip to content

Commit a3c9399

Browse files
authored
Rebootstrap on top of cleaned up dist logic (#5022)
1 parent 6dd381f commit a3c9399

File tree

4 files changed

+1
-1491
lines changed

4 files changed

+1
-1491
lines changed

build.mill

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//| mill-version: 0.13.0-M2-19-7fbdc2
1+
//| mill-version: 0.13.0-M2-29-d4e08d
22

33
package build
44
// imports

ci/mill-bootstrap.patch

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +0,0 @@
1-
diff --git a/dist/package.mill b/dist/package.mill
2-
index c16347a6a19..f1c2303e45b 100644
3-
--- a/dist/package.mill
4-
+++ b/dist/package.mill
5-
@@ -336,84 +336,6 @@ object `package` extends InstallModule {
6-
7-
object JvmWorkerGraalvm extends JvmWorkerModule {
8-
def jvmId = build.Settings.graalvmJvmId
9-
-
10-
- import coursier.cache.{ArchiveCache, FileCache}
11-
- import coursier.jvm.{JavaHome, JvmCache}
12-
- import coursier.util.{Task => CsTask}
13-
- import mill.api.Result
14-
- import scala.util.Properties.isWin
15-
-
16-
- def javaHome: T[Option[PathRef]] = Task {
17-
- Option(jvmId()).filter(_ != "").map { id =>
18-
- val path = resolveJavaHome(
19-
- id = id,
20-
- coursierCacheCustomizer = coursierCacheCustomizer(),
21-
- ctx = Some(Task.ctx()),
22-
- jvmIndexVersion = jvmIndexVersion(),
23-
- useShortPaths = isWin && (
24-
- jvmId().startsWith("graalvm") || jvmId().startsWith("liberica-nik")
25-
- )
26-
- ).get
27-
- // Java home is externally managed, better revalidate it at least once
28-
- PathRef(path, quick = true).withRevalidateOnce
29-
- }
30-
- }
31-
-
32-
- def resolveJavaHome(
33-
- id: String,
34-
- ctx: Option[mill.define.TaskCtx] = None,
35-
- coursierCacheCustomizer: Option[FileCache[CsTask] => FileCache[CsTask]] = None,
36-
- jvmIndexVersion: String = mill.api.BuildInfo.coursierJvmIndexVersion,
37-
- useShortPaths: Boolean = false
38-
- ): Result[os.Path] = {
39-
- val coursierCache0 =
40-
- FileCache() // .withLogger(new CoursierTickerResolutionLogger(Task.ctx))
41-
- val shortPathDirOpt = Option.when(useShortPaths) {
42-
- if (isWin)
43-
- // On Windows, prefer to use System.getenv over sys.env (or ctx.env for
44-
- // now), as the former respects the case-insensitiveness of env vars on
45-
- // Windows, while the latter doesn't
46-
- os.Path(System.getenv("UserProfile")) / ".mill/cache/jvm"
47-
- else {
48-
- val cacheBase = ctx.map(_.env)
49-
- .getOrElse(sys.env)
50-
- .get("XDG_CACHE_HOME")
51-
- .map(os.Path(_))
52-
- .getOrElse(os.home / ".cache")
53-
- cacheBase / "mill/jvm"
54-
- }
55-
- }
56-
- val jvmCache = JvmCache()
57-
- .withArchiveCache(
58-
- ArchiveCache()
59-
- .withCache(coursierCache0)
60-
- // .withShortPathDirectory(shortPathDirOpt.map(_.toIO))
61-
- )
62-
- .withIndex(Jvm.jvmIndex0(ctx, coursierCacheCustomizer, jvmIndexVersion))
63-
- val javaHome = JavaHome()
64-
- .withCache(jvmCache)
65-
- // when given a version like "17", always pick highest version in the index
66-
- // rather than the highest already on disk
67-
- .withUpdate(true)
68-
- val file = os.Path(javaHome.get(id).unsafeRun()(coursierCache0.ec))
69-
- val finalDir = shortPathDirOpt match {
70-
- case None => file
71-
- case Some(shortPathDir) =>
72-
- val sha1 = {
73-
- import java.math.BigInteger
74-
- import java.security.MessageDigest
75-
- val bytes = MessageDigest.getInstance("SHA-1").digest(file.toString.getBytes)
76-
- val baseSha1 = new BigInteger(1, bytes).toString(16)
77-
- "0" * (40 - baseSha1.length) + baseSha1
78-
- }
79-
- val dir = shortPathDir / sha1.take(8)
80-
- os.copy(file, dir, createFolders = true)
81-
- dir
82-
- }
83-
- Result.Success(finalDir)
84-
-
85-
- }
86-
-
87-
}
88-
}
89-
}

dist/package.mill

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -284,84 +284,6 @@ object `package` extends MillJavaModule with DistModule {
284284

285285
object JvmWorkerGraalvm extends JvmWorkerModule {
286286
def jvmId = build.Settings.graalvmJvmId
287-
288-
import coursier.cache.{ArchiveCache, FileCache}
289-
import coursier.jvm.{JavaHome, JvmCache}
290-
import coursier.util.{Task => CsTask}
291-
import mill.api.Result
292-
import scala.util.Properties.isWin
293-
294-
def javaHome: T[Option[PathRef]] = Task {
295-
Option(jvmId()).filter(_ != "").map { id =>
296-
val path = resolveJavaHome(
297-
id = id,
298-
coursierCacheCustomizer = coursierCacheCustomizer(),
299-
ctx = Some(Task.ctx()),
300-
jvmIndexVersion = jvmIndexVersion(),
301-
useShortPaths = isWin && (
302-
jvmId().startsWith("graalvm") || jvmId().startsWith("liberica-nik")
303-
)
304-
).get
305-
// Java home is externally managed, better revalidate it at least once
306-
PathRef(path, quick = true).withRevalidateOnce
307-
}
308-
}
309-
310-
def resolveJavaHome(
311-
id: String,
312-
ctx: Option[mill.define.TaskCtx] = None,
313-
coursierCacheCustomizer: Option[FileCache[CsTask] => FileCache[CsTask]] = None,
314-
jvmIndexVersion: String = mill.api.BuildInfo.coursierJvmIndexVersion,
315-
useShortPaths: Boolean = false
316-
): Result[os.Path] = {
317-
val coursierCache0 =
318-
FileCache() // .withLogger(new CoursierTickerResolutionLogger(Task.ctx))
319-
val shortPathDirOpt = Option.when(useShortPaths) {
320-
if (isWin)
321-
// On Windows, prefer to use System.getenv over sys.env (or ctx.env for
322-
// now), as the former respects the case-insensitiveness of env vars on
323-
// Windows, while the latter doesn't
324-
os.Path(System.getenv("UserProfile")) / ".mill/cache/jvm"
325-
else {
326-
val cacheBase = ctx.map(_.env)
327-
.getOrElse(sys.env)
328-
.get("XDG_CACHE_HOME")
329-
.map(os.Path(_))
330-
.getOrElse(os.home / ".cache")
331-
cacheBase / "mill/jvm"
332-
}
333-
}
334-
val jvmCache = JvmCache()
335-
.withArchiveCache(
336-
ArchiveCache()
337-
.withCache(coursierCache0)
338-
// .withShortPathDirectory(shortPathDirOpt.map(_.toIO))
339-
)
340-
.withIndex(Jvm.jvmIndex0(ctx, coursierCacheCustomizer, jvmIndexVersion))
341-
val javaHome = JavaHome()
342-
.withCache(jvmCache)
343-
// when given a version like "17", always pick highest version in the index
344-
// rather than the highest already on disk
345-
.withUpdate(true)
346-
val file = os.Path(javaHome.get(id).unsafeRun()(coursierCache0.ec))
347-
val finalDir = shortPathDirOpt match {
348-
case None => file
349-
case Some(shortPathDir) =>
350-
val sha1 = {
351-
import java.math.BigInteger
352-
import java.security.MessageDigest
353-
val bytes = MessageDigest.getInstance("SHA-1").digest(file.toString.getBytes)
354-
val baseSha1 = new BigInteger(1, bytes).toString(16)
355-
"0" * (40 - baseSha1.length) + baseSha1
356-
}
357-
val dir = shortPathDir / sha1.take(8)
358-
os.copy(file, dir, createFolders = true)
359-
dir
360-
}
361-
Result.Success(finalDir)
362-
363-
}
364-
365287
}
366288
}
367289
}

0 commit comments

Comments
 (0)