/
RootModule.scala
55 lines (49 loc) · 2.03 KB
/
RootModule.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package mill.main
import mill.api.internal
import mill.define.{Caller, Discover, Segments}
/**
* Used to mark a module in your `build.sc` as a top-level module, so it's
* targets and commands can be run directly e.g. via `mill run` rather than
* prefixed by the module name `mill foo.run`.
*
* Only one top-level module may be defined in your `build.sc`, and it must be
* defined at the top level of the `build.sc` and not nested in any other
* modules.
*/
abstract class RootModule()(implicit
baseModuleInfo: RootModule.Info,
millModuleEnclosing0: sourcecode.Enclosing,
millModuleLine0: sourcecode.Line,
millFile0: sourcecode.File
) extends mill.define.BaseModule(baseModuleInfo.millSourcePath0)(
millModuleEnclosing0,
millModuleLine0,
millFile0,
Caller(null)
) with mill.main.MainModule {
// Make BaseModule take the `millDiscover` as an implicit param, rather than
// defining it itself. That is so we can define it externally in the wrapper
// code and it have it automatically passed to both the wrapper BaseModule as
// well as any user-defined BaseModule that may be present, so the
// user-defined BaseModule can have a complete Discover[_] instance without
// needing to tediously call `override lazy val millDiscover = Discover[this.type]`
override lazy val millDiscover: Discover[this.type] =
baseModuleInfo.discover.asInstanceOf[Discover[this.type]]
}
@internal
object RootModule {
case class Info(millSourcePath0: os.Path, discover: Discover[_])
abstract class Foreign(foreign0: Option[Segments])(implicit
baseModuleInfo: RootModule.Info,
millModuleEnclosing0: sourcecode.Enclosing,
millModuleLine0: sourcecode.Line,
millFile0: sourcecode.File
) extends mill.define.BaseModule(baseModuleInfo.millSourcePath0, foreign0 = foreign0)(
millModuleEnclosing0,
millModuleLine0,
millFile0,
Caller(null)
) with mill.main.MainModule {
override implicit lazy val millDiscover: Discover[this.type] = Discover[this.type]
}
}