Skip to content

Commit b60bdbf

Browse files
authored
Make show not rely on cached .json files to allow proper handling of build overrides (#6558)
This way the `.json` file can be an accurate representation of the underlying `Task`, with the build override applied in memory uncached. This ensures the underlying task caches are invalidated correctly
1 parent c594690 commit b60bdbf

File tree

7 files changed

+179
-68
lines changed

7 files changed

+179
-68
lines changed

core/api/src/mill/api/Task.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ object Task {
126126

127127
def fail(msg: String)(using ctx: mill.api.TaskCtx): Nothing = ctx.fail(msg)
128128

129+
/**
130+
* Generate JSON representation for a worker task result.
131+
* Workers don't have a JSON writer, so we generate a special JSON format.
132+
*/
133+
def workerJson(taskName: String, value: Any, inputsHash: Int): ujson.Obj =
134+
ujson.Obj(
135+
"worker" -> ujson.Str(taskName),
136+
"toString" -> ujson.Str(value.toString),
137+
"inputsHash" -> ujson.Num(inputsHash)
138+
)
139+
129140
/**
130141
* Converts a `Seq[Task[T]]` into a `Task[Seq[T]]`
131142
*/

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

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -398,20 +398,9 @@ trait GroupExecution {
398398
val (mergedData, serializedPaths) = PathRef.withSerializedPaths {
399399
(taskValue ++ yamlValue.asInstanceOf[Seq[Any]]).asInstanceOf[Any]
400400
}
401-
// Write merged result to disk cache so `show` can read it.
402-
// Note: This overwrites the task cache, causing the task to re-execute
403-
// on subsequent runs even if task inputs haven't changed. This is a
404-
// trade-off to support `show` displaying the correct merged value.
405-
labelled.writerOpt.foreach { w =>
406-
val json =
407-
upickle.writeJs(mergedData)(using w.asInstanceOf[upickle.Writer[Any]])
408-
writeCacheJson(
409-
paths.meta,
410-
json,
411-
mergedData.##,
412-
inputsHash + appendLocated.value.value.##
413-
)
414-
}
401+
// Don't write merged result to paths.meta - that would overwrite the task
402+
// cache and cause the task to re-execute every time. The task cache stays
403+
// valid with inputsHash, and show uses the in-memory result from newResults.
415404
taskResults.copy(
416405
newResults =
417406
Map(labelled -> ExecResult.Success(Val(mergedData), mergedData.##)),
@@ -590,11 +579,7 @@ trait GroupExecution {
590579
upickle.writeJs(v.value)(using w.asInstanceOf[upickle.Writer[Any]])
591580
}
592581
lazy val workerJson = labelled.asWorker.map { _ =>
593-
ujson.Obj(
594-
"worker" -> ujson.Str(labelled.toString),
595-
"toString" -> ujson.Str(v.value.toString),
596-
"inputsHash" -> ujson.Num(inputsHash)
597-
) -> Nil
582+
Task.workerJson(labelled.toString, v.value, inputsHash) -> Nil
598583
}
599584

600585
val terminalResult: Option[(ujson.Value, Seq[PathRef])] = labelled

integration/feature/full-run-logs/src/FullRunLogsFailureTests.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,15 @@ object FullRunLogsFailureTests extends UtestIntegrationTestSuite {
183183
"(R)java.lang.Exception(X): boom",
184184
" (R)build_.package_.exceptionHelper(X)((R)build.mill(X):(R)6(X))",
185185
" (R)build_.package_.exception$$anonfun$1(X)((R)build.mill(X):(R)8(X))",
186-
" (R)mill.api.Task$Named.evaluate(X)((R)Task.scala(X):(R)394(X))",
187-
" (R)mill.api.Task$Named.evaluate$(X)((R)Task.scala(X):(R)379(X))",
188-
" (R)mill.api.Task$Command.evaluate(X)((R)Task.scala(X):(R)466(X))",
186+
" (R)mill.api.Task$Named.evaluate(X)((R)Task.scala(X):(R)405(X))",
187+
" (R)mill.api.Task$Named.evaluate$(X)((R)Task.scala(X):(R)390(X))",
188+
" (R)mill.api.Task$Command.evaluate(X)((R)Task.scala(X):(R)477(X))",
189189
"(R)java.lang.RuntimeException(X): bang",
190190
" (R)build_.package_.exceptionHelper(X)((R)build.mill(X):(R)6(X))",
191191
" (R)build_.package_.exception$$anonfun$1(X)((R)build.mill(X):(R)8(X))",
192-
" (R)mill.api.Task$Named.evaluate(X)((R)Task.scala(X):(R)394(X))",
193-
" (R)mill.api.Task$Named.evaluate$(X)((R)Task.scala(X):(R)379(X))",
194-
" (R)mill.api.Task$Command.evaluate(X)((R)Task.scala(X):(R)466(X))"
192+
" (R)mill.api.Task$Named.evaluate(X)((R)Task.scala(X):(R)405(X))",
193+
" (R)mill.api.Task$Named.evaluate$(X)((R)Task.scala(X):(R)390(X))",
194+
" (R)mill.api.Task$Command.evaluate(X)((R)Task.scala(X):(R)477(X))"
195195
)
196196
)
197197
}

integration/migrating/init/resources/golden/gradle/ehcache3

Lines changed: 112 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,9 +1305,14 @@ Module dependencies of spi-tester:
13051305
"organization": "org.ehcache.modules.clustered",
13061306
"url": "http://ehcache.org",
13071307
"licenses": [
1308-
"The Apache Software License, Version 2.0"
1308+
{
1309+
"name": "The Apache Software License, Version 2.0",
1310+
"url": ""
1311+
}
13091312
],
1310-
"versionControl": "https://github.com/ehcache/ehcache3",
1313+
"versionControl": {
1314+
"browsableRepository": "https://github.com/ehcache/ehcache3"
1315+
},
13111316
"developers": [
13121317
{
13131318
"name": "Terracotta Engineers",
@@ -1320,9 +1325,14 @@ Module dependencies of spi-tester:
13201325
"organization": "org.ehcache",
13211326
"url": "http://ehcache.org",
13221327
"licenses": [
1323-
"The Apache Software License, Version 2.0"
1328+
{
1329+
"name": "The Apache Software License, Version 2.0",
1330+
"url": ""
1331+
}
13241332
],
1325-
"versionControl": "https://github.com/ehcache/ehcache3",
1333+
"versionControl": {
1334+
"browsableRepository": "https://github.com/ehcache/ehcache3"
1335+
},
13261336
"developers": [
13271337
{
13281338
"name": "Terracotta Engineers",
@@ -1335,9 +1345,14 @@ Module dependencies of spi-tester:
13351345
"organization": "org.ehcache.modules.clustered",
13361346
"url": "http://ehcache.org",
13371347
"licenses": [
1338-
"The Apache Software License, Version 2.0"
1348+
{
1349+
"name": "The Apache Software License, Version 2.0",
1350+
"url": ""
1351+
}
13391352
],
1340-
"versionControl": "https://github.com/ehcache/ehcache3",
1353+
"versionControl": {
1354+
"browsableRepository": "https://github.com/ehcache/ehcache3"
1355+
},
13411356
"developers": [
13421357
{
13431358
"name": "Terracotta Engineers",
@@ -1350,9 +1365,14 @@ Module dependencies of spi-tester:
13501365
"organization": "org.ehcache.modules.clustered",
13511366
"url": "http://ehcache.org",
13521367
"licenses": [
1353-
"The Apache Software License, Version 2.0"
1368+
{
1369+
"name": "The Apache Software License, Version 2.0",
1370+
"url": ""
1371+
}
13541372
],
1355-
"versionControl": "https://github.com/ehcache/ehcache3",
1373+
"versionControl": {
1374+
"browsableRepository": "https://github.com/ehcache/ehcache3"
1375+
},
13561376
"developers": [
13571377
{
13581378
"name": "Terracotta Engineers",
@@ -1365,9 +1385,14 @@ Module dependencies of spi-tester:
13651385
"organization": "org.ehcache.modules.clustered",
13661386
"url": "http://ehcache.org",
13671387
"licenses": [
1368-
"The Apache Software License, Version 2.0"
1388+
{
1389+
"name": "The Apache Software License, Version 2.0",
1390+
"url": ""
1391+
}
13691392
],
1370-
"versionControl": "https://github.com/ehcache/ehcache3",
1393+
"versionControl": {
1394+
"browsableRepository": "https://github.com/ehcache/ehcache3"
1395+
},
13711396
"developers": [
13721397
{
13731398
"name": "Terracotta Engineers",
@@ -1380,9 +1405,14 @@ Module dependencies of spi-tester:
13801405
"organization": "org.ehcache.modules.clustered",
13811406
"url": "http://ehcache.org",
13821407
"licenses": [
1383-
"The Apache Software License, Version 2.0"
1408+
{
1409+
"name": "The Apache Software License, Version 2.0",
1410+
"url": ""
1411+
}
13841412
],
1385-
"versionControl": "https://github.com/ehcache/ehcache3",
1413+
"versionControl": {
1414+
"browsableRepository": "https://github.com/ehcache/ehcache3"
1415+
},
13861416
"developers": [
13871417
{
13881418
"name": "Terracotta Engineers",
@@ -1395,9 +1425,14 @@ Module dependencies of spi-tester:
13951425
"organization": "org.ehcache.modules.clustered",
13961426
"url": "http://ehcache.org",
13971427
"licenses": [
1398-
"The Apache Software License, Version 2.0"
1428+
{
1429+
"name": "The Apache Software License, Version 2.0",
1430+
"url": ""
1431+
}
13991432
],
1400-
"versionControl": "https://github.com/ehcache/ehcache3",
1433+
"versionControl": {
1434+
"browsableRepository": "https://github.com/ehcache/ehcache3"
1435+
},
14011436
"developers": [
14021437
{
14031438
"name": "Terracotta Engineers",
@@ -1410,9 +1445,14 @@ Module dependencies of spi-tester:
14101445
"organization": "org.ehcache",
14111446
"url": "http://ehcache.org",
14121447
"licenses": [
1413-
"The Apache Software License, Version 2.0"
1448+
{
1449+
"name": "The Apache Software License, Version 2.0",
1450+
"url": ""
1451+
}
14141452
],
1415-
"versionControl": "https://github.com/ehcache/ehcache3",
1453+
"versionControl": {
1454+
"browsableRepository": "https://github.com/ehcache/ehcache3"
1455+
},
14161456
"developers": [
14171457
{
14181458
"name": "Terracotta Engineers",
@@ -1425,9 +1465,14 @@ Module dependencies of spi-tester:
14251465
"organization": "org.ehcache.modules",
14261466
"url": "http://ehcache.org",
14271467
"licenses": [
1428-
"The Apache Software License, Version 2.0"
1468+
{
1469+
"name": "The Apache Software License, Version 2.0",
1470+
"url": ""
1471+
}
14291472
],
1430-
"versionControl": "https://github.com/ehcache/ehcache3",
1473+
"versionControl": {
1474+
"browsableRepository": "https://github.com/ehcache/ehcache3"
1475+
},
14311476
"developers": [
14321477
{
14331478
"name": "Terracotta Engineers",
@@ -1440,9 +1485,14 @@ Module dependencies of spi-tester:
14401485
"organization": "org.ehcache.modules",
14411486
"url": "http://ehcache.org",
14421487
"licenses": [
1443-
"The Apache Software License, Version 2.0"
1488+
{
1489+
"name": "The Apache Software License, Version 2.0",
1490+
"url": ""
1491+
}
14441492
],
1445-
"versionControl": "https://github.com/ehcache/ehcache3",
1493+
"versionControl": {
1494+
"browsableRepository": "https://github.com/ehcache/ehcache3"
1495+
},
14461496
"developers": [
14471497
{
14481498
"name": "Terracotta Engineers",
@@ -1455,9 +1505,14 @@ Module dependencies of spi-tester:
14551505
"organization": "org.ehcache.modules",
14561506
"url": "http://ehcache.org",
14571507
"licenses": [
1458-
"The Apache Software License, Version 2.0"
1508+
{
1509+
"name": "The Apache Software License, Version 2.0",
1510+
"url": ""
1511+
}
14591512
],
1460-
"versionControl": "https://github.com/ehcache/ehcache3",
1513+
"versionControl": {
1514+
"browsableRepository": "https://github.com/ehcache/ehcache3"
1515+
},
14611516
"developers": [
14621517
{
14631518
"name": "Terracotta Engineers",
@@ -1470,9 +1525,14 @@ Module dependencies of spi-tester:
14701525
"organization": "org.ehcache.modules",
14711526
"url": "http://ehcache.org",
14721527
"licenses": [
1473-
"The Apache Software License, Version 2.0"
1528+
{
1529+
"name": "The Apache Software License, Version 2.0",
1530+
"url": ""
1531+
}
14741532
],
1475-
"versionControl": "https://github.com/ehcache/ehcache3",
1533+
"versionControl": {
1534+
"browsableRepository": "https://github.com/ehcache/ehcache3"
1535+
},
14761536
"developers": [
14771537
{
14781538
"name": "Terracotta Engineers",
@@ -1485,9 +1545,14 @@ Module dependencies of spi-tester:
14851545
"organization": "org.ehcache.modules",
14861546
"url": "http://ehcache.org",
14871547
"licenses": [
1488-
"The Apache Software License, Version 2.0"
1548+
{
1549+
"name": "The Apache Software License, Version 2.0",
1550+
"url": ""
1551+
}
14891552
],
1490-
"versionControl": "https://github.com/ehcache/ehcache3",
1553+
"versionControl": {
1554+
"browsableRepository": "https://github.com/ehcache/ehcache3"
1555+
},
14911556
"developers": [
14921557
{
14931558
"name": "Terracotta Engineers",
@@ -1500,9 +1565,14 @@ Module dependencies of spi-tester:
15001565
"organization": "org.ehcache",
15011566
"url": "http://ehcache.org",
15021567
"licenses": [
1503-
"The Apache Software License, Version 2.0"
1568+
{
1569+
"name": "The Apache Software License, Version 2.0",
1570+
"url": ""
1571+
}
15041572
],
1505-
"versionControl": "https://github.com/ehcache/ehcache3",
1573+
"versionControl": {
1574+
"browsableRepository": "https://github.com/ehcache/ehcache3"
1575+
},
15061576
"developers": [
15071577
{
15081578
"name": "Terracotta Engineers",
@@ -1515,9 +1585,14 @@ Module dependencies of spi-tester:
15151585
"organization": "org.ehcache.modules",
15161586
"url": "http://ehcache.org",
15171587
"licenses": [
1518-
"The Apache Software License, Version 2.0"
1588+
{
1589+
"name": "The Apache Software License, Version 2.0",
1590+
"url": ""
1591+
}
15191592
],
1520-
"versionControl": "https://github.com/ehcache/ehcache3",
1593+
"versionControl": {
1594+
"browsableRepository": "https://github.com/ehcache/ehcache3"
1595+
},
15211596
"developers": [
15221597
{
15231598
"name": "Terracotta Engineers",
@@ -1530,9 +1605,14 @@ Module dependencies of spi-tester:
15301605
"organization": "org.ehcache.modules",
15311606
"url": "http://ehcache.org",
15321607
"licenses": [
1533-
"The Apache Software License, Version 2.0"
1608+
{
1609+
"name": "The Apache Software License, Version 2.0",
1610+
"url": ""
1611+
}
15341612
],
1535-
"versionControl": "https://github.com/ehcache/ehcache3",
1613+
"versionControl": {
1614+
"browsableRepository": "https://github.com/ehcache/ehcache3"
1615+
},
15361616
"developers": [
15371617
{
15381618
"name": "Terracotta Engineers",

integration/migrating/init/resources/golden/gradle/fast-csv

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,18 @@ null
7171
"organization": "de.siegmar",
7272
"url": "https://fastcsv.org",
7373
"licenses": [
74-
"MIT License"
74+
{
75+
"id": "MIT",
76+
"name": "MIT License",
77+
"url": "https://spdx.org/licenses/MIT.html",
78+
"isOsiApproved": true,
79+
"isFsfLibre": true,
80+
"distribution": "repo"
81+
}
7582
],
76-
"versionControl": "https://github.com/osiegmar/FastCSV",
83+
"versionControl": {
84+
"browsableRepository": "https://github.com/osiegmar/FastCSV"
85+
},
7786
"developers": [
7887
{
7988
"name": "Oliver Siegmar"

0 commit comments

Comments
 (0)