Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More doc root-module tweaking #3842

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading