Skip to content

Commit 5a63c36

Browse files
authored
Cleanup mill.api package (#5478)
- Rename `RootModule0` -> `RootModule` - Rename `BaseModule` -> `RootModule0` - Privatize `mill.api.Lazy` - Rename `TaskModule` to `DefaultTaskModule` - Privatize `Mirrors`
1 parent a0bad84 commit 5a63c36

File tree

56 files changed

+238
-215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+238
-215
lines changed

ci/mill-bootstrap.patch

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/build.mill b/build.mill
2-
index bb60d3b7bee..78ec19509ea 100644
2+
index c87279ddc31..ab3f79762c0 100644
33
--- a/build.mill
44
+++ b/build.mill
55
@@ -10,12 +10,12 @@ import millbuild.*
@@ -18,7 +18,7 @@ index bb60d3b7bee..78ec19509ea 100644
1818
import mill.api.SelectMode
1919
import mill.T
2020
diff --git a/contrib/package.mill b/contrib/package.mill
21-
index 38f05bccde9..1cbbd237d33 100644
21+
index 82bcca15874..7b019a583a6 100644
2222
--- a/contrib/package.mill
2323
+++ b/contrib/package.mill
2424
@@ -5,7 +5,7 @@ import coursier.maven.MavenRepository
@@ -193,7 +193,7 @@ index ef25e2a891f..11e78faf6da 100644
193193
+// def mimaExcludeAnnotations = Seq("mill.api.internal.internal", "mill.api.experimental")
194194
}
195195
diff --git a/website/package.mill b/website/package.mill
196-
index dd0965f8778..ee1476b87fa 100644
196+
index 9b215a2dfc2..3184bc4112d 100644
197197
--- a/website/package.mill
198198
+++ b/website/package.mill
199199
@@ -105,7 +105,7 @@ object `package` extends mill.Module {
@@ -223,6 +223,15 @@ index dd0965f8778..ee1476b87fa 100644
223223
)
224224
PathRef(Task.dest)
225225
}
226+
@@ -304,7 +304,7 @@ object `package` extends mill.Module {
227+
)
228+
229+
def oldDocSources = Task {
230+
- Task.traverse(oldDocs.items.map(_.module))(_.value.oldDocSource)()
231+
+ Task.traverse(oldDocs.items.map(_.module))(_().oldDocSource)()
232+
}
233+
234+
object oldDocs extends Cross[OldDocModule](versionLabels)
226235
@@ -352,7 +352,7 @@ object `package` extends mill.Module {
227236

228237
expandDiagramsInDirectoryAdocFile(

contrib/playlib/readme.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ be find for a production deployment.
190190

191191
== Using `RootModule`
192192

193-
The `RootModule0` abstract class allows you to have the build descriptor at the same level as the
193+
The `RootModule` abstract class allows you to have the build descriptor at the same level as the
194194
source code on the filesystem. You can move from there to a multi-module build either by refactoring
195195
your directory layout into multiple subdirectories or by using mill's nested modules feature.
196196

@@ -237,7 +237,7 @@ The directory layout was:
237237
└── controllers
238238
----
239239

240-
by extending `RootModule0` in your build:
240+
by extending `RootModule` in your build:
241241

242242
.`build.mill`
243243
[source,scala]

core/api/src/mill/api/BaseModule.scala

Lines changed: 0 additions & 35 deletions
This file was deleted.

core/api/src/mill/api/Cross.scala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,17 @@ object Cross {
158158
*/
159159
trait Cross[M <: Cross.Module[?]](factories: Cross.Factory[M]*) extends mill.api.Module {
160160

161+
private class Lazy[T](t: () => T) extends Function0[T] {
162+
lazy val value: T = t()
163+
def apply(): T = value
164+
}
165+
161166
val ctx: ModuleCtx = moduleCtx
162167

163168
trait Item {
164169
def crossValues: List[Any]
165170
def crossSegments: List[String]
166-
def module: Lazy[M]
171+
def module: Function0[M]
167172
def cls: Class[?]
168173
}
169174

@@ -209,7 +214,7 @@ trait Cross[M <: Cross.Module[?]](factories: Cross.Factory[M]*) extends mill.api
209214
* A list of the cross modules, in
210215
* the order the original cross values were given in
211216
*/
212-
lazy val crossModules: Seq[M] = items.map(_.module.value)
217+
lazy val crossModules: Seq[M] = items.map(_.module())
213218

214219
/**
215220
* A mapping of the raw cross values to the cross modules, in
@@ -219,7 +224,7 @@ trait Cross[M <: Cross.Module[?]](factories: Cross.Factory[M]*) extends mill.api
219224
.map { i => (i.crossValues, i.module) }
220225
.to(collection.mutable.LinkedHashMap)
221226
.view
222-
.mapValues(_.value)
227+
.mapValues(_())
223228

224229
/**
225230
* A mapping of the string-ified string segments to the cross modules, in
@@ -229,7 +234,7 @@ trait Cross[M <: Cross.Module[?]](factories: Cross.Factory[M]*) extends mill.api
229234
.map { i => (i.crossSegments, i.module) }
230235
.to(collection.mutable.LinkedHashMap)
231236
.view
232-
.mapValues(_.value)
237+
.mapValues(_())
233238

234239
/**
235240
* The default cross segments to use, when no cross value is specified.

core/api/src/mill/api/TaskModule.scala renamed to core/api/src/mill/api/DefaultTaskModule.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package mill.api
44
* A [[Module]] that has a [[defaultTask]] that will be automatically
55
* executed if the module name is provide at the Mill command line
66
*/
7-
trait TaskModule extends Module {
7+
trait DefaultTaskModule extends Module {
88

99
/**
1010
* The name of the default command, which will be automatically executed if

core/api/src/mill/api/Evaluator.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import mill.api.*
55
import mill.api.daemon.Watchable
66
import mill.api.BuildCtx
77
import mill.api.daemon.internal.{EvaluatorApi, TaskApi}
8+
import mill.api.internal.RootModule0
9+
810
import scala.util.DynamicVariable
911
import scala.collection.mutable
1012
import scala.jdk.CollectionConverters.*
@@ -25,7 +27,7 @@ trait Evaluator extends AutoCloseable with EvaluatorApi {
2527
private[mill] def outPath: os.Path
2628
private[mill] def outPathJava = outPath.toNIO
2729
private[mill] def codeSignatures: Map[String, Int]
28-
private[mill] def rootModule: BaseModule
30+
private[mill] def rootModule: RootModule0
2931
private[mill] def workerCache: mutable.Map[String, (Int, Val)]
3032
private[mill] def env: Map[String, String]
3133
private[mill] def effectiveThreadCount: Int

core/api/src/mill/api/ExternalModule.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package mill.api
22

3+
import mill.api.internal.RootModule0
4+
35
/**
46
* A module defined outside of the `build.mill` file, and is instead
57
* provided builtin by some Mill library or plugin
@@ -13,7 +15,7 @@ abstract class ExternalModule(implicit
1315
millModuleEnclosing0: sourcecode.Enclosing,
1416
millModuleLine0: sourcecode.Line,
1517
millFile0: sourcecode.File
16-
) extends BaseModule(BuildCtx.workspaceRoot, external0 = true)(
18+
) extends RootModule0(BuildCtx.workspaceRoot, external0 = true)(
1719
millModuleEnclosing0,
1820
millModuleLine0,
1921
millFile0

core/api/src/mill/api/Lazy.scala

Lines changed: 0 additions & 5 deletions
This file was deleted.

core/api/src/mill/api/ModuleCtx.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package mill.api
22

3-
import mill.api.internal.OverrideMapping
3+
import mill.api.internal.{RootModule0, OverrideMapping}
44

55
import scala.annotation.{compileTimeOnly, implicitNotFound}
66

@@ -80,7 +80,7 @@ object ModuleCtx extends LowPriCtx {
8080
private[mill] def millSourcePath: os.Path
8181

8282
/**
83-
* The full path of this task or module, from the [[BaseModule]]
83+
* The full path of this task or module, from the [[RootModule0]]
8484
*/
8585
private[mill] def segments: Segments
8686

@@ -90,7 +90,7 @@ object ModuleCtx extends LowPriCtx {
9090
private[mill] def external: Boolean
9191

9292
/**
93-
* The [[Discover]] instance associate with this [[BaseModule]] hierarchy
93+
* The [[Discover]] instance associate with this [[RootModule0]] hierarchy
9494
*/
9595
private[mill] def discover: Discover
9696

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package mill.api.internal
22

33
import mill.api.BuildCtx
44

5-
class BuildFileCls(rootModule0: => mill.api.internal.RootModule0)
5+
class BuildFileCls(rootModule0: => mill.api.internal.RootModule)
66
extends mill.api.daemon.internal.BuildFileApi {
77
def value = this
88
def checker = mill.api.internal.ResolveChecker(BuildCtx.workspaceRoot)

0 commit comments

Comments
 (0)