Skip to content

Commit 75875ba

Browse files
authored
Write meta .json files to disk for build overrides to support show (#6088)
Fixes #5745
1 parent 091066c commit 75875ba

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

core/exec/src/mill/exec/GroupExecution.scala

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ trait GroupExecution {
114114
terminal match {
115115

116116
case labelled: Task.Named[_] =>
117-
117+
val out = if (!labelled.ctx.external) outPath else externalOutPath
118+
val paths = ExecutionPaths.resolve(out, labelled.ctx.segments)
118119
labelled.ctx.segments.last.value match {
119120
// apply build override
120121
case single if labelled.ctx.enclosingModule.buildOverrides.contains(single) =>
@@ -131,6 +132,9 @@ trait GroupExecution {
131132
)
132133
}
133134
}
135+
136+
// Write build header override JSON to meta `.json` file to support `show`
137+
writeCacheJson(paths.meta, jsonData, resultData.hashCode, inputsHash)
134138
(ExecResult.Success(Val(resultData), resultData.##), serializedPaths)
135139
} catch {
136140
case e: upickle.core.TraceVisitor.TraceException =>
@@ -154,8 +158,6 @@ trait GroupExecution {
154158

155159
// no build overrides
156160
case _ =>
157-
val out = if (!labelled.ctx.external) outPath else externalOutPath
158-
val paths = ExecutionPaths.resolve(out, labelled.ctx.segments)
159161
val cached = loadCachedJson(logger, inputsHash, labelled, paths)
160162

161163
// `cached.isEmpty` means worker metadata file removed by user so recompute the worker
@@ -415,20 +417,21 @@ trait GroupExecution {
415417

416418
terminalResult match {
417419
case Some((json, serializedPaths)) =>
418-
os.write.over(
419-
metaPath,
420-
upickle.stream(
421-
mill.api.Cached(json, hashCode, inputsHash),
422-
indent = 4
423-
),
424-
createFolders = true
425-
)
420+
writeCacheJson(metaPath, json, hashCode, inputsHash)
426421
serializedPaths
427422
case _ =>
428423
Nil
429424
}
430425
}
431426

427+
def writeCacheJson(metaPath: os.Path, json: ujson.Value, hashCode: Int, inputsHash: Int) = {
428+
os.write.over(
429+
metaPath,
430+
upickle.stream(mill.api.Cached(json, hashCode, inputsHash), indent = 4),
431+
createFolders = true
432+
)
433+
}
434+
432435
def resolveLogger(
433436
logPath: Option[os.Path],
434437
logger: mill.api.Logger

0 commit comments

Comments
 (0)