Skip to content

Commit

Permalink
More doc root-module tweaking (#3842)
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi authored Oct 25, 2024
1 parent 4cf615e commit 1d0d5fd
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion example/javalib/basic/2-custom-build-logic/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package build
import mill._, javalib._

object `package` extends RootModule with JavaModule {
object foo extends JavaModule {
/** Total number of lines in module source files */
def lineCount = Task {
allSourceFiles().map(f => os.read.lines(f.path).size).sum
Expand Down
2 changes: 1 addition & 1 deletion example/kotlinlib/basic/2-custom-build-logic/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package build
import mill._, kotlinlib._

object `package` extends RootModule with KotlinModule {
object foo extends KotlinModule {

def kotlinVersion = "1.9.24"

Expand Down
25 changes: 16 additions & 9 deletions example/scalalib/basic/2-custom-build-logic/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package build
import mill._, scalalib._

object `package` extends RootModule with ScalaModule {
object foo extends ScalaModule {
def scalaVersion = "2.13.11"

/** Total number of lines in module source files */
Expand Down Expand Up @@ -46,26 +46,31 @@ object `package` extends RootModule with ScalaModule {

/** Usage

> mill run
> mill foo.run
...
Line Count: 17

> mill show lineCount
> mill show foo.lineCount
17

> mill inspect lineCount
lineCount(build.mill:...)
> mill inspect foo.lineCount
foo.lineCount(build.mill:...)
Total number of lines in module source files
Inputs:
allSourceFiles
foo.allSourceFiles
*/

// Above, `def lineCount` is a new build task we define, which makes use of
// `allSourceFiles` (an existing task) and is in-turn used in our override of
// `resources` (also an existing task). `os.read.lines` and `os.write` come
// `resources` (also an existing task). This generated file can then be
// loaded and used at runtime, as see in the output of `mill run`.
//
// `os.read.lines` and `os.write` come
// from the https://github.com/com-lihaoyi/os-lib[OS-Lib] library, which is
// one of Mill's xref:fundamentals/bundled-libraries.adoc[Bundled Libraries]. This generated file can then be
// loaded and used at runtime, as see in the output of `mill run`
// one of Mill's xref:fundamentals/bundled-libraries.adoc[Bundled Libraries].
// You can also import any other library you want from Maven Central using
// xref:extending/import-ivy-plugins.adoc[import $ivy], so you are not limited
// to what is bundled with Mill.
//
// If you're not familiar with what existing tasks are available to override and
// how they interact with one another, you can explore them via autocomplete or
Expand All @@ -90,3 +95,5 @@ Inputs:
// While these things may not matter for such a simple example that runs
// quickly, they ensure that custom build logic remains performant and
// maintainable even as the complexity of your project grows.
//

5 changes: 2 additions & 3 deletions example/scalalib/basic/3-multi-module/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ object bar extends MyModule {
}
//// SNIPPET:END

// This example contains a simple Mill build with two modules, `foo` and `bar`.
// We don't mark either module as top-level using `extends RootModule`, so
// running tasks needs to use the module name as the prefix e.g. `foo.run` or
// This example contains a simple Mill build with two modules, `foo` and `bar`,
// which you can run tasks on such as `foo.run` or
// `bar.run`. You can define multiple modules the same way you define a single
// module, using `def moduleDeps` to define the relationship between them. Modules
// can also be nested within each other, as `foo.test` and `bar.test` are nested
Expand Down

0 comments on commit 1d0d5fd

Please sign in to comment.