Skip to content

Commit 32888ba

Browse files
committed
.
1 parent 5892515 commit 32888ba

File tree

5 files changed

+30
-14
lines changed

5 files changed

+30
-14
lines changed

core/api/src/mill/api/internal/RootModule.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ object RootModule {
3939
val topLevelProjectRoot: os.Path,
4040
val buildOverrides: Map[String, ujson.Value]
4141
) {
42+
mill.constants.DebugLog.println("buildOverrides " + buildOverrides)
43+
mill.constants.DebugLog.println("projectRoot " + projectRoot)
4244
def this(
4345
projectRoot: os.Path,
4446
output: os.Path,
@@ -48,12 +50,12 @@ object RootModule {
4850
projectRoot0: String,
4951
output0: String,
5052
topLevelProjectRoot0: String,
51-
@com.lihaoyi.unroll buildOverrides: ujson.Value = Map()
53+
headerData: String
5254
) = this(
5355
os.Path(projectRoot0),
5456
os.Path(output0),
5557
os.Path(topLevelProjectRoot0),
56-
upickle.read[Map[String, ujson.Value]](buildOverrides)
58+
upickle.read[Map[String, ujson.Value]](headerData)
5759
)
5860
implicit val millMiscInfo: Info = this
5961
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ trait GroupExecution {
104104
labelled.ctx.segments.last.value match {
105105
case single if labelled.ctx.enclosingModule.buildOverrides.contains(single) =>
106106
val jsonData = labelled.ctx.enclosingModule.buildOverrides(single)
107+
107108
import collection.JavaConverters._
108109
def rec(x: ujson.Value): ujson.Value = x match{
109110
case ujson.Str(s) => mill.constants.Util.interpolateEnvVars(s, envWithPwd.asJava)

runner/daemon/src/mill/daemon/MillBuildBootstrap.scala

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ class MillBuildBootstrap(
9898
os.exists(currentRoot / rootBuildFileName)
9999
)
100100

101-
val (nestedState, headerDataOpt) =
101+
val nestedState =
102102
if (depth == 0) {
103103
// On this level we typically want to assume a Mill project, which means we want to require an existing `build.mill`.
104104
// Unfortunately, some tasks also make sense without a `build.mill`, e.g. the `init` command.
105105
// Hence, we only report a missing `build.mill` as a problem if the command itself does not succeed.
106106
lazy val state = evaluateRec(depth + 1)
107-
if (currentRootContainsBuildFile) (state, None)
107+
if (currentRootContainsBuildFile) state
108108
else {
109109
val msg =
110110
s"No build file (${rootBuildFileNames.asScala.mkString(", ")}) found in $projectRoot. Are you in a Mill project directory?"
@@ -118,7 +118,7 @@ class MillBuildBootstrap(
118118
case state => state
119119
}
120120
}
121-
(res, None)
121+
res
122122
}
123123
} else {
124124
val parsedScriptFiles = FileImportGraph
@@ -134,12 +134,17 @@ class MillBuildBootstrap(
134134
else {
135135
val bootstrapModule =
136136
new MillBuildRootModule.BootstrapModule()(
137-
using new RootModule.Info(currentRoot, output, projectRoot)
137+
using new RootModule.Info(
138+
currentRoot,
139+
output,
140+
projectRoot,
141+
upickle.read[Map[String, ujson.Value]](mill.internal.Util.parseHeaderData(parsedScriptFiles.headerData))
142+
)
138143
)
139144
RunnerState(Some(bootstrapModule), Nil, None, Some(parsedScriptFiles.buildFile))
140145
}
141146

142-
(state, Some(parsedScriptFiles.headerData))
147+
state
143148
}
144149

145150
val classloaderChanged =

runner/meta/src/mill/meta/CodeGen.scala

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ object CodeGen {
2121
supportDest: os.Path,
2222
millTopLevelProjectRoot: os.Path,
2323
output: os.Path,
24-
parser: MillScalaParser
24+
parser: MillScalaParser,
25+
headerData: String
2526
): Unit = {
2627
val scriptSources = allScriptCode.keys.toSeq.sorted
2728
for (scriptPath <- scriptSources) breakable {
@@ -104,7 +105,8 @@ object CodeGen {
104105
scriptFolderPath = scriptFolderPath,
105106
segments = segments,
106107
millTopLevelProjectRoot = millTopLevelProjectRoot,
107-
output = output
108+
output = output,
109+
headerData = headerData
108110
)
109111

110112
os.write(supportDestDir / "MillMiscInfo.scala", miscInfo, createFolders = true)
@@ -160,15 +162,17 @@ object CodeGen {
160162
scriptFolderPath: os.Path,
161163
segments: Seq[String],
162164
millTopLevelProjectRoot: os.Path,
163-
output: os.Path
165+
output: os.Path,
166+
headerData: String
164167
): String = {
165168
val header = if (pkg.isBlank()) "" else s"package $pkg"
166169
val body =
167170
if (segments.nonEmpty) subfolderMiscInfo(scriptFolderPath, segments)
168171
else rootMiscInfo(
169172
scriptFolderPath,
170173
millTopLevelProjectRoot,
171-
output
174+
output,
175+
headerData
172176
)
173177

174178
s"""|$generatedFileHeader
@@ -321,14 +325,17 @@ object CodeGen {
321325
def rootMiscInfo(
322326
scriptFolderPath: os.Path,
323327
millTopLevelProjectRoot: os.Path,
324-
output: os.Path
328+
output: os.Path,
329+
headerData: String
325330
): String = {
331+
val headerJson = ujson.Obj.from(mill.internal.Util.parseHeaderData(headerData)).render()
326332
s"""|@_root_.scala.annotation.nowarn
327333
|object MillMiscInfo
328334
| extends mill.api.internal.RootModule.Info(
329335
| projectRoot0 = ${literalize(scriptFolderPath.toString)},
330336
| output0 = ${literalize(output.toString)},
331-
| topLevelProjectRoot0 = ${literalize(millTopLevelProjectRoot.toString)}
337+
| topLevelProjectRoot0 = ${literalize(millTopLevelProjectRoot.toString)},
338+
| headerData = ${literalize(headerJson)}
332339
|)
333340
|""".stripMargin
334341
}

runner/meta/src/mill/meta/MillBuildRootModule.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ trait MillBuildRootModule()(implicit
119119
support,
120120
rootModuleInfo.topLevelProjectRoot,
121121
rootModuleInfo.output,
122-
MillScalaParser.current.value
122+
MillScalaParser.current.value,
123+
parsed.headerData
123124
)
124125
(wrapped = Seq(PathRef(wrapped)), support = Seq(PathRef(support)))
125126
}

0 commit comments

Comments
 (0)