From 4f70fd6c392a4acae12f43a292d8f88d84e912c0 Mon Sep 17 00:00:00 2001 From: Myyk Seok <2080820+myyk@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:29:56 +0800 Subject: [PATCH] Apply Scalafmt to `examples/` in CI (#3903) Partially completes: #3829 Tested locally by breaking format of `example/scalalib/basic/1-simple/foo/src/Foo.scala` by just adding a bunch of spaces. * Observe break with `./mill mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources` failure. * Observe fix with `./mill mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources` Used `// format: off` rather than changing [docstrings.style = keep](https://scalameta.org/scalafmt/docs/configuration.html#docstringsstyle--keep) to our `.scalafmt.conf` since that would affect all files. There doesn't seem to be a built in way in ScalaFmt to have folder level configs or something like this. I thought it might be better to not have `example` be an exception cases if we can avoid it. I'm not sure if the `// format: off` comments break something else though. --- .scalafmt.conf | 18 +++++++- .../src/mill/contrib/jmh/JmhModuleTest.scala | 11 ++--- .../10-multi-file-builds/bar/package.mill | 2 +- .../large/10-multi-file-builds/build.mill | 2 +- .../10-multi-file-builds/foo/src/Foo.scala | 6 ++- .../depth/large/11-helper-files/build.mill | 6 +-- .../large/11-helper-files/foo/versions.mill | 2 +- .../depth/large/12-helper-files-sc/build.sc | 10 ++--- .../large/12-helper-files-sc/foo/versions.sc | 2 +- .../build.mill.scala | 5 +-- .../foo/versions.mill.scala | 2 +- example/depth/sandbox/1-task/build.mill | 6 +-- example/depth/sandbox/2-test/build.mill | 6 +-- example/depth/sandbox/3-breaking/build.mill | 2 +- .../extending/imports/1-import-ivy/build.mill | 3 +- .../imports/2-import-ivy-scala/build.mill | 3 +- .../imports/3-contrib-import/build.mill | 5 +-- .../3-contrib-import/foo/src/Foo.scala | 2 +- .../extending/jvmcode/1-subprocess/build.mill | 6 +-- .../jvmcode/2-classloader/build.mill | 8 ++-- example/extending/jvmcode/3-worker/build.mill | 12 +++-- .../4-module-run-task/bar/src/Bar.scala | 4 +- .../jvmcode/4-module-run-task/build.mill | 4 +- .../jvmcode/5-module-classloader/build.mill | 4 +- .../metabuild/3-autoformatting/build.mill | 3 +- .../metabuild/4-meta-build/build.mill | 6 +-- .../4-meta-build/mill-build/build.mill | 4 +- .../5-meta-shared-sources/build.mill | 4 +- .../mill-build/build.mill | 2 +- .../mill-build/src/ScalaVersion.scala | 2 +- .../newlang/1-hello-typescript/build.mill | 19 ++++---- .../newlang/2-typescript-modules/build.mill | 16 +++---- .../newlang/3-module-deps/build.mill | 26 +++++------ .../newlang/4-npm-deps-bundle/build.mill | 45 ++++++++++--------- .../plugins/7-writing-mill-plugins/build.mill | 9 ++-- .../myplugin/src/LineCountJavaModule.scala | 4 +- .../resources/example-test-project/build.mill | 4 +- .../integration-test-project/build.mill | 3 +- .../test/src/mill/testkit/UnitTests.scala | 1 - .../cross/10-static-blog/build.mill | 8 ++-- .../cross/11-default-cross-module/build.mill | 3 -- .../cross/2-cross-source-path/build.mill | 2 +- .../cross/3-outside-dependency/build.mill | 3 +- .../cross/4-cross-dependencies/build.mill | 2 +- .../cross/5-multiple-cross-axes/build.mill | 2 +- .../cross/6-axes-extension/build.mill | 2 +- .../cross/7-inner-cross-module/build.mill | 8 ++-- .../fundamentals/cross/8-resolvers/build.mill | 2 +- .../cross/9-dynamic-cross-modules/build.mill | 4 +- .../dependencies/1-search-updates/build.mill | 3 +- .../fundamentals/libraries/1-oslib/build.mill | 2 +- .../libraries/2-upickle/build.mill | 6 +-- .../libraries/4-mainargs/build.mill | 12 ++--- .../modules/11-abstract-module-ref/build.mill | 7 ++- .../fundamentals/modules/6-modules/build.mill | 7 ++- .../modules/7-root-module/build.mill | 3 +- .../modules/8-diy-java-modules/build.mill | 5 +-- .../modules/9-backticked-names/build.mill | 2 +- .../out-dir/1-custom-out/build.mill | 1 - .../tasks/1-task-graph/build.mill | 4 +- .../tasks/2-primary-tasks/build.mill | 15 +++---- .../tasks/3-anonymous-tasks/build.mill | 3 +- .../fundamentals/tasks/4-inputs/build.mill | 11 +++-- .../tasks/5-persistent-tasks/build.mill | 2 +- .../fundamentals/tasks/6-workers/build.mill | 10 ++--- .../tasks/7-forking-futures/build.mill | 6 +-- example/javalib/web/1-hello-jetty/build.mill | 1 - .../web/2-hello-spring-boot/build.mill | 1 - .../javalib/web/3-todo-spring-boot/build.mill | 11 +++-- .../javalib/web/4-hello-micronaut/build.mill | 10 ++--- .../javalib/web/5-todo-micronaut/build.mill | 12 +++-- example/package.mill | 1 + example/scalalib/basic/1-simple/build.mill | 4 +- .../basic/2-custom-build-logic/build.mill | 2 - .../scalalib/basic/3-multi-module/build.mill | 1 - .../basic/3-multi-module/foo/src/Foo.scala | 6 ++- .../basic/4-compat-modules/build.mill | 4 +- .../basic/5-builtin-commands/build.mill | 5 --- .../5-builtin-commands/foo/src/Foo.scala | 6 ++- example/scalalib/basic/6-realistic/build.mill | 2 +- .../2-run-compile-deps/build.mill | 3 -- .../dependencies/3-unmanaged-jars/build.mill | 1 - .../5-repository-config/build.mill | 3 +- .../scalalib/linting/1-scalafmt/build.mill | 2 +- .../linting/2-contrib-scoverage/build.mill | 2 +- example/scalalib/linting/3-acyclic/build.mill | 1 - .../scalalib/linting/3-acyclic/src/Bar.scala | 2 +- .../scalalib/linting/3-acyclic/src/Foo.scala | 4 +- .../module/1-common-config/build.mill | 8 ++-- .../1-common-config/custom-src/Foo2.scala | 1 - .../scalalib/module/11-main-class/build.mill | 2 +- .../module/13-assembly-config/build.mill | 2 +- .../module/14-cross-scala-version/build.mill | 5 +-- example/scalalib/module/15-unidoc/build.mill | 6 +-- .../scalalib/module/2-custom-tasks/build.mill | 4 +- .../module/3-override-tasks/build.mill | 2 +- .../4-compilation-execution-flags/build.mill | 3 +- .../scalalib/module/7-resources/build.mill | 6 --- .../7-resources/foo/test/src/FooTests.scala | 2 +- .../module/9-docjar/bar/src/Bar.scala | 1 + example/scalalib/module/9-docjar/build.mill | 4 +- example/scalalib/native/1-simple/build.mill | 2 +- .../scalalib/native/1-simple/src/Foo.scala | 7 ++- .../native/1-simple/test/src/FooTests.scala | 1 - example/scalalib/native/2-interop/build.mill | 2 - .../native/2-interop/src/foo/HelloWorld.scala | 1 - .../2-interop/test/src/HelloWorldTests.scala | 1 - .../native/3-multi-module/bar/src/Bar.scala | 2 - .../bar/test/src/BarTests.scala | 1 - .../native/3-multi-module/foo/src/Foo.scala | 28 +++++++----- .../native/4-common-config/build.mill | 2 - .../native/4-common-config/src/Foo.scala | 5 +-- .../scalalib/testing/1-test-suite/build.mill | 3 +- .../scalalib/testing/2-test-deps/build.mill | 2 - .../testing/3-integration-suite/build.mill | 4 +- .../testing/4-test-grouping/build.mill | 3 +- example/scalalib/web/1-todo-webapp/build.mill | 4 +- .../web/2-webapp-cache-busting/build.mill | 3 +- .../scalalib/web/3-scalajs-module/build.mill | 2 +- .../scalalib/web/4-webapp-scalajs/build.mill | 4 +- .../client/src/ClientApp.scala | 11 ++--- .../web/5-webapp-scalajs-shared/build.mill | 6 +-- .../client/src/ClientApp.scala | 12 ++--- .../shared/src/Shared.scala | 2 +- .../build.mill | 5 ++- example/scalalib/web/8-wasm/build.mill | 3 -- .../src/MultiLevelBuildTests.scala | 11 ++--- .../js/KotlinJsKotestModuleTests.scala | 4 +- ...KotlinJsKotlinTestPackageModuleTests.scala | 4 +- main/define/src/mill/define/Cross.scala | 3 +- main/server/src/mill/main/server/Server.scala | 4 +- main/util/src/mill/util/PromptLogger.scala | 4 +- .../test/src/mill/util/PipeStreamsTests.scala | 4 +- runner/src/mill/runner/MillCliConfig.scala | 3 +- .../mill/scalalib/TestModuleUtilTests.scala | 2 + 135 files changed, 327 insertions(+), 372 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 3c94eb345e9..ca282ea5224 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = "3.8.3" +version = "3.8.4-RC1" align.openParenCallSite = false align.preset = none @@ -21,3 +21,19 @@ project.git = true runner.dialect = scala213 +project { + excludePaths = [ + "glob:**/example/scalalib/linting/1-scalafmt/src/Foo.scala", + "glob:**/mill/out/**" + ] +} + +fileOverride { + "glob:**/example/**/build.mill*" { + docstrings.style = keep + } + "glob:**/example/**/build.sc" { + docstrings.style = keep + } + "glob:**/example/scalalib/native/**/*.scala" = scala3 +} \ No newline at end of file diff --git a/contrib/jmh/test/src/mill/contrib/jmh/JmhModuleTest.scala b/contrib/jmh/test/src/mill/contrib/jmh/JmhModuleTest.scala index b5f526d9e8a..75348c4d31b 100644 --- a/contrib/jmh/test/src/mill/contrib/jmh/JmhModuleTest.scala +++ b/contrib/jmh/test/src/mill/contrib/jmh/JmhModuleTest.scala @@ -24,11 +24,12 @@ object JmhModuleTest extends TestSuite { val paths = EvaluatorPaths.resolveDestPaths(eval.outPath, jmh.listJmhBenchmarks()) val outFile = paths.dest / "benchmarks.out" val Right(result) = eval(jmh.listJmhBenchmarks("-o", outFile.toString)) - val expected = """Benchmarks: - |mill.contrib.jmh.Bench2.log - |mill.contrib.jmh.Bench2.sqrt - |mill.contrib.jmh.Bench1.measureShared - |mill.contrib.jmh.Bench1.measureUnshared""".stripMargin + val expected = + """Benchmarks: + |mill.contrib.jmh.Bench2.log + |mill.contrib.jmh.Bench2.sqrt + |mill.contrib.jmh.Bench1.measureShared + |mill.contrib.jmh.Bench1.measureUnshared""".stripMargin val out = os.read.lines(outFile).map(_.trim).mkString(System.lineSeparator()) assert(out == expected) } diff --git a/example/depth/large/10-multi-file-builds/bar/package.mill b/example/depth/large/10-multi-file-builds/bar/package.mill index e8a442dd075..eed442dfb22 100644 --- a/example/depth/large/10-multi-file-builds/bar/package.mill +++ b/example/depth/large/10-multi-file-builds/bar/package.mill @@ -1 +1 @@ -package build.bar \ No newline at end of file +package build.bar diff --git a/example/depth/large/10-multi-file-builds/build.mill b/example/depth/large/10-multi-file-builds/build.mill index 04fb82a1cf0..3493636b715 100644 --- a/example/depth/large/10-multi-file-builds/build.mill +++ b/example/depth/large/10-multi-file-builds/build.mill @@ -56,4 +56,4 @@ BarQux.value:
world
// `package.mill` files are only discovered in direct subfolders of the root `build.mill` or // subfolders of another folder containing a `package.mill`; Hence in this example, we need // an `bar/package.mill` to be present for `bar/qux/package.mill` to be discovered, even -// though `bar/package.mill` is empty \ No newline at end of file +// though `bar/package.mill` is empty diff --git a/example/depth/large/10-multi-file-builds/foo/src/Foo.scala b/example/depth/large/10-multi-file-builds/foo/src/Foo.scala index 7e1c4d86e91..ff66a55bd8f 100644 --- a/example/depth/large/10-multi-file-builds/foo/src/Foo.scala +++ b/example/depth/large/10-multi-file-builds/foo/src/Foo.scala @@ -4,8 +4,10 @@ object Foo { val value = "hello" @main - def main(@arg(name = "foo-text") fooText: String, - @arg(name = "bar-qux-text") barQuxText: String): Unit = { + def main( + @arg(name = "foo-text") fooText: String, + @arg(name = "bar-qux-text") barQuxText: String + ): Unit = { println("Foo.value: " + Foo.value) bar.qux.BarQux.printText(barQuxText) } diff --git a/example/depth/large/11-helper-files/build.mill b/example/depth/large/11-helper-files/build.mill index 58de0e8eb8b..1fde0fa661c 100644 --- a/example/depth/large/11-helper-files/build.mill +++ b/example/depth/large/11-helper-files/build.mill @@ -1,4 +1,3 @@ - // Apart from having `package` files in subfolders to define modules, Mill // also allows you to have helper code in any `*.mill` file in the same folder // as your `build.mill` or a `package.mill`. @@ -9,10 +8,10 @@ import mill._, scalalib._ import $file.foo.versions import $file.util.MyModule -object `package` extends RootModule with MyModule{ +object `package` extends RootModule with MyModule { def forkEnv = Map( "MY_SCALA_VERSION" -> build.scalaVersion(), - "MY_PROJECT_VERSION" -> versions.myProjectVersion, + "MY_PROJECT_VERSION" -> versions.myProjectVersion ) } @@ -20,7 +19,6 @@ object `package` extends RootModule with MyModule{ /** See Also: foo/package.mill */ /** See Also: foo/versions.mill */ - // // Different helper scripts and ``build.mill``/``package`` files can all refer to // each other using the `build` object, which marks the root object of your build. diff --git a/example/depth/large/11-helper-files/foo/versions.mill b/example/depth/large/11-helper-files/foo/versions.mill index d2d0681b67c..53c0cdf2301 100644 --- a/example/depth/large/11-helper-files/foo/versions.mill +++ b/example/depth/large/11-helper-files/foo/versions.mill @@ -1,3 +1,3 @@ package build.foo -def myProjectVersion = "0.0.1" \ No newline at end of file +def myProjectVersion = "0.0.1" diff --git a/example/depth/large/12-helper-files-sc/build.sc b/example/depth/large/12-helper-files-sc/build.sc index 2dc4f1881d4..e82973e3353 100644 --- a/example/depth/large/12-helper-files-sc/build.sc +++ b/example/depth/large/12-helper-files-sc/build.sc @@ -4,26 +4,24 @@ // current `.mill` extension with `package` declaration, so you should use `.mill` whenever // possible - import mill._, scalalib._ import $packages._ import $file.foo.versions import $file.util, util.MyModule -object `package` extends RootModule with MyModule{ - def forkEnv = T{ +object `package` extends RootModule with MyModule { + def forkEnv = T { Map( "MY_SCALA_VERSION" -> build.scalaVersion(), - "MY_PROJECT_VERSION" -> versions.myProjectVersion, + "MY_PROJECT_VERSION" -> versions.myProjectVersion ) } } + /** See Also: util.sc */ /** See Also: foo/package.sc */ /** See Also: foo/versions.sc */ - - /** Usage > ./mill run diff --git a/example/depth/large/12-helper-files-sc/foo/versions.sc b/example/depth/large/12-helper-files-sc/foo/versions.sc index 2b180a26f3a..002f35f1335 100644 --- a/example/depth/large/12-helper-files-sc/foo/versions.sc +++ b/example/depth/large/12-helper-files-sc/foo/versions.sc @@ -1 +1 @@ -def myProjectVersion = "0.0.1" \ No newline at end of file +def myProjectVersion = "0.0.1" diff --git a/example/depth/large/13-helper-files-mill-scala/build.mill.scala b/example/depth/large/13-helper-files-mill-scala/build.mill.scala index 1767b93da59..35ce38e6611 100644 --- a/example/depth/large/13-helper-files-mill-scala/build.mill.scala +++ b/example/depth/large/13-helper-files-mill-scala/build.mill.scala @@ -4,17 +4,16 @@ import mill._, scalalib._ import $file.foo.versions import $file.util.MyModule -object `package` extends RootModule with MyModule{ +object `package` extends RootModule with MyModule { def forkEnv = Map( "MY_SCALA_VERSION" -> build.scalaVersion(), - "MY_PROJECT_VERSION" -> versions.myProjectVersion, + "MY_PROJECT_VERSION" -> versions.myProjectVersion ) } ///** See Also: util.mill.scala */ ///** See Also: foo/package.mill.scala */ ///** See Also: foo/versions.mill.scala */ - // Apart from having `package` files in subfolders to define modules, Mill // also allows you to have helper code in any `*.mill` file in the same folder // as your `build.mill` or a `package.mill`. diff --git a/example/depth/large/13-helper-files-mill-scala/foo/versions.mill.scala b/example/depth/large/13-helper-files-mill-scala/foo/versions.mill.scala index d2d0681b67c..53c0cdf2301 100644 --- a/example/depth/large/13-helper-files-mill-scala/foo/versions.mill.scala +++ b/example/depth/large/13-helper-files-mill-scala/foo/versions.mill.scala @@ -1,3 +1,3 @@ package build.foo -def myProjectVersion = "0.0.1" \ No newline at end of file +def myProjectVersion = "0.0.1" diff --git a/example/depth/sandbox/1-task/build.mill b/example/depth/sandbox/1-task/build.mill index f5f133f36da..6f0e7f269b4 100644 --- a/example/depth/sandbox/1-task/build.mill +++ b/example/depth/sandbox/1-task/build.mill @@ -14,7 +14,7 @@ package build import mill._ -object foo extends Module{ +object foo extends Module { def tDestTask = Task { println(Task.dest.toString) } } @@ -23,7 +23,6 @@ object foo extends Module{ .../out/foo/tDestTask.dest */ - // === Task `os.pwd` redirection // Mill also redirects the `os.pwd` property from https://github.com/com-lihaoyi/os-lib[OS-Lib], // such that that also points towards a running task's own `.dest/` folder @@ -62,7 +61,6 @@ def externalPwdTask = Task { println(externalPwd.toString) } .../out/mill-server/.../sandbox */ - // === Limitations of Mill's Sandboxing // // Mill's approach to filesystem sandboxing is designed to avoid accidental interference @@ -72,4 +70,4 @@ def externalPwdTask = Task { println(externalPwd.toString) } // outside of Mill's control. // // However, by setting `os.pwd` to safe sandbox folders, we hope to minimize the cases where -// someone accidentally causes issues with their build by doing the wrong thing. \ No newline at end of file +// someone accidentally causes issues with their build by doing the wrong thing. diff --git a/example/depth/sandbox/2-test/build.mill b/example/depth/sandbox/2-test/build.mill index 08449fb18d8..6ef74cd7a16 100644 --- a/example/depth/sandbox/2-test/build.mill +++ b/example/depth/sandbox/2-test/build.mill @@ -5,11 +5,11 @@ package build import mill._, javalib._ -trait MyModule extends JavaModule{ +trait MyModule extends JavaModule { object test extends JavaTests with TestModule.Junit4 } -object foo extends MyModule{ +object foo extends MyModule { def moduleDeps = Seq(bar) } @@ -68,4 +68,4 @@ object bar extends MyModule // sandbox folder via `..` or from the root folder `/` or home folder `~/`. // Nevertheless, it should add some simple guardrails to prevent many common // causes of inter-test interference, letting your test suite run in parallel both -// quickly and reliably \ No newline at end of file +// quickly and reliably diff --git a/example/depth/sandbox/3-breaking/build.mill b/example/depth/sandbox/3-breaking/build.mill index 3d7c0a2739f..546c9201a3f 100644 --- a/example/depth/sandbox/3-breaking/build.mill +++ b/example/depth/sandbox/3-breaking/build.mill @@ -21,7 +21,7 @@ def myTask = Task { println(Task.workspace) } // Whereas `MILL_WORKSPACE_ROOT` as well as in tests, which can access the // workspace root via the `MILL_WORKSPACE_ROOT` environment variable -object foo extends JavaModule{ +object foo extends JavaModule { object test extends JavaTests with TestModule.Junit4 } diff --git a/example/extending/imports/1-import-ivy/build.mill b/example/extending/imports/1-import-ivy/build.mill index 0911b1220aa..1263f61dcd7 100644 --- a/example/extending/imports/1-import-ivy/build.mill +++ b/example/extending/imports/1-import-ivy/build.mill @@ -1,4 +1,3 @@ - // The following example shows how to import the library `org.thymeleaf:thymeleaf:3.1.1.RELEASE` // into your build, so you can use it at build-time to safely generate escaped HTML snippets // in your resource path for your application to use. @@ -20,7 +19,7 @@ object foo extends JavaModule { ) } - def resources = Task.Sources{ + def resources = Task.Sources { os.write(Task.dest / "snippet.txt", htmlSnippet()) super.resources() ++ Seq(PathRef(Task.dest)) } diff --git a/example/extending/imports/2-import-ivy-scala/build.mill b/example/extending/imports/2-import-ivy-scala/build.mill index 12c7a763b68..b23bb9aeb49 100644 --- a/example/extending/imports/2-import-ivy-scala/build.mill +++ b/example/extending/imports/2-import-ivy-scala/build.mill @@ -11,7 +11,7 @@ object bar extends ScalaModule { def ivyDeps = Agg(ivy"com.lihaoyi::os-lib:0.10.7") def htmlSnippet = Task { div(h1("hello"), p("world")).toString } - def resources = Task.Sources{ + def resources = Task.Sources { os.write(Task.dest / "snippet.txt", htmlSnippet()) super.resources() ++ Seq(PathRef(Task.dest)) } @@ -22,7 +22,6 @@ object bar extends ScalaModule { // Note that using `import $ivy` on Scala libraries requires a double colon `::` between // the organization name and artifact name. - /** Usage > mill bar.compile diff --git a/example/extending/imports/3-contrib-import/build.mill b/example/extending/imports/3-contrib-import/build.mill index a847c3d8816..3948c97b7dc 100644 --- a/example/extending/imports/3-contrib-import/build.mill +++ b/example/extending/imports/3-contrib-import/build.mill @@ -7,11 +7,10 @@ object foo extends ScalaModule with BuildInfo { def scalaVersion = "2.13.10" def buildInfoPackageName = "foo" def buildInfoMembers = Seq( - BuildInfo.Value("scalaVersion", scalaVersion()), + BuildInfo.Value("scalaVersion", scalaVersion()) ) } - // This example illustrates usage of Mill `contrib` plugins. These are Mill // plugins contributed by Mill user that are maintained within the Mill // repo, published under `mill-contrib-*`. @@ -33,4 +32,4 @@ foo.BuildInfo.scalaVersion: 2.13.10 // // * Like third-party plugins, contrib modules are submitted by third-parties, // and do now maintain the same binary compatibility guarantees of Mill's -// builtin comdules \ No newline at end of file +// builtin comdules diff --git a/example/extending/imports/3-contrib-import/foo/src/Foo.scala b/example/extending/imports/3-contrib-import/foo/src/Foo.scala index 0a2c6b82ca3..6fb98e135ff 100644 --- a/example/extending/imports/3-contrib-import/foo/src/Foo.scala +++ b/example/extending/imports/3-contrib-import/foo/src/Foo.scala @@ -1,5 +1,5 @@ package foo -object Foo{ +object Foo { def main(args: Array[String]): Unit = { println("foo.BuildInfo.scalaVersion: " + foo.BuildInfo.scalaVersion) } diff --git a/example/extending/jvmcode/1-subprocess/build.mill b/example/extending/jvmcode/1-subprocess/build.mill index 3f2c83357b5..f84e7dad5cb 100644 --- a/example/extending/jvmcode/1-subprocess/build.mill +++ b/example/extending/jvmcode/1-subprocess/build.mill @@ -18,13 +18,13 @@ import mill._, javalib._ import mill.util.Jvm object foo extends JavaModule { - def groovyClasspath: Task[Agg[PathRef]] = Task{ + def groovyClasspath: Task[Agg[PathRef]] = Task { defaultResolver().resolveDeps(Agg(ivy"org.codehaus.groovy:groovy:3.0.9")) } def groovyScript = Task.Source(millSourcePath / "generate.groovy") - def groovyGeneratedResources = Task{ + def groovyGeneratedResources = Task { Jvm.runSubprocess( mainClass = "groovy.ui.GroovyMain", classPath = groovyClasspath().map(_.path), @@ -62,4 +62,4 @@ Contents of groovy-generated.html isGroovy!
// As mentioned above, `defaultResolver().resolveDeps` and `Jvm.runSubprocess` are an // alternative to `import $ivy`, providing you more flexibility to resolve dependencies // on-demand as part of your task graph only when necessary, and keeping it isolated from -// the build in a subprocess preventing classpath collisions. \ No newline at end of file +// the build in a subprocess preventing classpath collisions. diff --git a/example/extending/jvmcode/2-classloader/build.mill b/example/extending/jvmcode/2-classloader/build.mill index c59279608c4..fb18c8643ff 100644 --- a/example/extending/jvmcode/2-classloader/build.mill +++ b/example/extending/jvmcode/2-classloader/build.mill @@ -10,14 +10,14 @@ import mill._, javalib._ import mill.util.Jvm object foo extends JavaModule { - def groovyClasspath: Task[Agg[PathRef]] = Task{ + def groovyClasspath: Task[Agg[PathRef]] = Task { defaultResolver().resolveDeps(Agg(ivy"org.codehaus.groovy:groovy:3.0.9")) } def groovyScript = Task.Source(millSourcePath / "generate.groovy") - def groovyGeneratedResources = Task{ - Jvm.runClassloader(classPath = groovyClasspath().map(_.path)){ classLoader => + def groovyGeneratedResources = Task { + Jvm.runClassloader(classPath = groovyClasspath().map(_.path)) { classLoader => classLoader .loadClass("groovy.ui.GroovyMain") .getMethod("main", classOf[Array[String]]) @@ -52,4 +52,4 @@ Contents of groovy-generated.html isGroovy!
// of wall-clock time and in terms of memory footprint. However, it does have somewhat less // isolation, as the code is running inside your JVM and cannot be configured to have a separate // working directory, environment variables, and other process-global configs. Which one is -// better to use differs on a case-by-case basis. \ No newline at end of file +// better to use differs on a case-by-case basis. diff --git a/example/extending/jvmcode/3-worker/build.mill b/example/extending/jvmcode/3-worker/build.mill index 843a328d695..f748dad04d7 100644 --- a/example/extending/jvmcode/3-worker/build.mill +++ b/example/extending/jvmcode/3-worker/build.mill @@ -15,18 +15,18 @@ import mill.util.Jvm object coursierModule extends CoursierModule -def groovyClasspath: Task[Agg[PathRef]] = Task{ +def groovyClasspath: Task[Agg[PathRef]] = Task { coursierModule.defaultResolver().resolveDeps(Agg(ivy"org.codehaus.groovy:groovy:3.0.9")) } -def groovyWorker: Worker[java.net.URLClassLoader] = Task.Worker{ +def groovyWorker: Worker[java.net.URLClassLoader] = Task.Worker { mill.api.ClassLoader.create(groovyClasspath().map(_.path.toIO.toURL).toSeq, parent = null) } trait GroovyGenerateJavaModule extends JavaModule { def groovyScript = Task.Source(millSourcePath / "generate.groovy") - def groovyGeneratedResources = Task{ + def groovyGeneratedResources = Task { val oldCl = Thread.currentThread().getContextClassLoader Thread.currentThread().setContextClassLoader(groovyWorker()) try { @@ -49,10 +49,10 @@ trait GroovyGenerateJavaModule extends JavaModule { def resources = super.resources() ++ Seq(groovyGeneratedResources()) } -object foo extends GroovyGenerateJavaModule{ +object foo extends GroovyGenerateJavaModule { def groovyGenerateArg = "Foo Groovy!" } -object bar extends GroovyGenerateJavaModule{ +object bar extends GroovyGenerateJavaModule { def groovyGenerateArg = "Bar Groovy!" } @@ -61,7 +61,6 @@ object bar extends GroovyGenerateJavaModule{ // method of `groovy.ui.GroovyMain`, which also happens to require us to set the // `ContextClassLoader` to work. - /** Usage > ./mill foo.run @@ -71,7 +70,6 @@ Contents of groovy-generated.html isFoo Groovy! Contents of groovy-generated.html is
Bar Groovy!
*/ - // Because the `URLClassLoader` within `groovyWorker` is long-lived, the code within the // classloader can be optimized by the JVM runtime, and would have less overhead than if // run in separate classloaders via `Jvm.runClassloader`. And because `URLClassLoader` diff --git a/example/extending/jvmcode/4-module-run-task/bar/src/Bar.scala b/example/extending/jvmcode/4-module-run-task/bar/src/Bar.scala index c47ffa7f1fd..12b6bd5eab0 100644 --- a/example/extending/jvmcode/4-module-run-task/bar/src/Bar.scala +++ b/example/extending/jvmcode/4-module-run-task/bar/src/Bar.scala @@ -2,9 +2,9 @@ package bar object Bar { def main(args: Array[String]) = { val dest = os.pwd - for(sourceStr <- args){ + for (sourceStr <- args) { val sourcePath = os.Path(sourceStr) - for(p <- os.walk(sourcePath) if p.ext == "scala"){ + for (p <- os.walk(sourcePath) if p.ext == "scala") { val text = os.read(p) val mangledText = text.replace("hello", "HELLO") val fileDest = dest / (p.subRelativeTo(sourcePath)) diff --git a/example/extending/jvmcode/4-module-run-task/build.mill b/example/extending/jvmcode/4-module-run-task/build.mill index 5e6472fcd39..00b8a1b6e3d 100644 --- a/example/extending/jvmcode/4-module-run-task/build.mill +++ b/example/extending/jvmcode/4-module-run-task/build.mill @@ -16,7 +16,7 @@ object foo extends ScalaModule { } } -object bar extends ScalaModule{ +object bar extends ScalaModule { def scalaVersion = "2.13.8" def ivyDeps = Agg(ivy"com.lihaoyi::os-lib:0.10.7") } @@ -61,5 +61,3 @@ Foo.value: HELLO // (implicit ctx: Ctx): Unit // } // ---- - - diff --git a/example/extending/jvmcode/5-module-classloader/build.mill b/example/extending/jvmcode/5-module-classloader/build.mill index f649e5c19b0..72eef8d2e6b 100644 --- a/example/extending/jvmcode/5-module-classloader/build.mill +++ b/example/extending/jvmcode/5-module-classloader/build.mill @@ -4,7 +4,6 @@ // `bar` code within an in-memory classloader via `Jvm.runClassloader` as // we saw earlier: - package build import mill._, scalalib._ import mill.util.Jvm @@ -13,7 +12,7 @@ object foo extends JavaModule { def moduleDeps = Seq(bar) def sources = Task { - Jvm.runClassloader(classPath = bar.runClasspath().map(_.path)){ classLoader => + Jvm.runClassloader(classPath = bar.runClasspath().map(_.path)) { classLoader => classLoader .loadClass("bar.Bar") .getMethod("main", classOf[Array[String]]) @@ -39,4 +38,3 @@ object bar extends JavaModule Foo.value: HELLO */ - diff --git a/example/extending/metabuild/3-autoformatting/build.mill b/example/extending/metabuild/3-autoformatting/build.mill index c42a1b0df9c..3978f2a460b 100644 --- a/example/extending/metabuild/3-autoformatting/build.mill +++ b/example/extending/metabuild/3-autoformatting/build.mill @@ -5,7 +5,7 @@ package build import mill._ -object foo extends Module {def task=Task{"2.13.4"}} +object foo extends Module { def task = Task { "2.13.4" } } /** See Also: .scalafmt.conf */ /** Usage @@ -28,4 +28,3 @@ object foo extends Module { def task = Task { "2.13.4" } } // source files with Scalafmt. It requires the tasks that refer to the source files as argument // * `sources` this selects the `sources` tasks of the meta-build, which at least contains // the `build.mill`. - diff --git a/example/extending/metabuild/4-meta-build/build.mill b/example/extending/metabuild/4-meta-build/build.mill index c27f162eb07..9e485be1108 100644 --- a/example/extending/metabuild/4-meta-build/build.mill +++ b/example/extending/metabuild/4-meta-build/build.mill @@ -11,7 +11,7 @@ object `package` extends RootModule with ScalaModule { ) def htmlSnippet = Task { h1("hello").toString } - def resources = Task.Sources{ + def resources = Task.Sources { os.write(Task.dest / "snippet.txt", htmlSnippet()) super.resources() ++ Seq(PathRef(Task.dest)) } @@ -56,7 +56,6 @@ Run-time HTML snippet:world
*/ - // This example is trivial, but in larger builds there may be much more scenarios // where you may want to keep the libraries used in your `build.mill` and the libraries // used in your application code consistent. With the `mill-build/build.mill` configuration @@ -68,7 +67,6 @@ Run-time HTML snippet:world
// This is useful for large projects where the build itself is a non-trivial // module which requires its own non-trivial customization. - // You can also run tasks on the meta-build by using the `--meta-level` // cli option. @@ -84,4 +82,4 @@ Run-time HTML snippet:world
.../mill-build/build.mill" -*/ \ No newline at end of file +*/ diff --git a/example/extending/metabuild/4-meta-build/mill-build/build.mill b/example/extending/metabuild/4-meta-build/mill-build/build.mill index 4eb598feb7a..a838db43899 100644 --- a/example/extending/metabuild/4-meta-build/mill-build/build.mill +++ b/example/extending/metabuild/4-meta-build/mill-build/build.mill @@ -1,7 +1,7 @@ package build import mill._, scalalib._ -object `package` extends MillBuildRootModule{ +object `package` extends MillBuildRootModule { val scalatagsVersion = "0.12.0" def ivyDeps = Agg(ivy"com.lihaoyi::scalatags:$scalatagsVersion") @@ -17,4 +17,4 @@ object `package` extends MillBuildRootModule{ ) super.generatedSources() ++ Seq(PathRef(Task.dest)) } -} \ No newline at end of file +} diff --git a/example/extending/metabuild/5-meta-shared-sources/build.mill b/example/extending/metabuild/5-meta-shared-sources/build.mill index bf9d83ebc5a..f72ee72640b 100644 --- a/example/extending/metabuild/5-meta-shared-sources/build.mill +++ b/example/extending/metabuild/5-meta-shared-sources/build.mill @@ -4,7 +4,7 @@ import mill._, scalalib._ object `package` extends RootModule with ScalaModule { def scalaVersion = millbuild.ScalaVersion.myScalaVersion - def sources = Task.Sources{ + def sources = Task.Sources { super.sources() ++ Seq(PathRef(millSourcePath / "mill-build/src")) } } @@ -43,4 +43,4 @@ scalaVersion: 2.13.10 // places: at build-time where possible to save time at runtime, and at runtime where // necessary to make use of user input. With the Mill meta-build, you can write logic // comprising the same source code and using the same libraries in both environments, -// giving you flexibility in where your logic ends up running \ No newline at end of file +// giving you flexibility in where your logic ends up running diff --git a/example/extending/metabuild/5-meta-shared-sources/mill-build/build.mill b/example/extending/metabuild/5-meta-shared-sources/mill-build/build.mill index 5980b7a0f78..5e6212fabac 100644 --- a/example/extending/metabuild/5-meta-shared-sources/mill-build/build.mill +++ b/example/extending/metabuild/5-meta-shared-sources/mill-build/build.mill @@ -1,4 +1,4 @@ package build import mill._ -object `package` extends MillBuildRootModule \ No newline at end of file +object `package` extends MillBuildRootModule diff --git a/example/extending/metabuild/5-meta-shared-sources/mill-build/src/ScalaVersion.scala b/example/extending/metabuild/5-meta-shared-sources/mill-build/src/ScalaVersion.scala index a735fddfea8..489a1fbdb84 100644 --- a/example/extending/metabuild/5-meta-shared-sources/mill-build/src/ScalaVersion.scala +++ b/example/extending/metabuild/5-meta-shared-sources/mill-build/src/ScalaVersion.scala @@ -1,4 +1,4 @@ package millbuild -object ScalaVersion{ +object ScalaVersion { def myScalaVersion = "2.13.10" } diff --git a/example/extending/newlang/1-hello-typescript/build.mill b/example/extending/newlang/1-hello-typescript/build.mill index d0266dfe342..51e7fae7ae4 100644 --- a/example/extending/newlang/1-hello-typescript/build.mill +++ b/example/extending/newlang/1-hello-typescript/build.mill @@ -9,11 +9,10 @@ // First, we need to use the `npm` CLI tool to install typescript and the `@types/node` // library necessary for accessing Node.js APIs: - package build import mill._ -def npmInstall = Task{ +def npmInstall = Task { os.call(("npm", "install", "--save-dev", "typescript@5.6.3", "@types/node@22.7.8")) PathRef(Task.dest) } @@ -41,7 +40,7 @@ def npmInstall = Task{ // on exactly which files within the source root they wish to pick up. def sources = Task.Source(millSourcePath / "src") -def allSources = Task{ +def allSources = Task { os.walk(sources().path).filter(_.ext == "ts").map(PathRef(_)) } @@ -52,13 +51,15 @@ def allSources = Task{ // upstream `npmInstall` task, passing it the sources, `--outDir`, `--types`, and `--typeRoots` // Again we return a `PathRef` to the `Task.dest` folder we output the compiled JS files to -def compile = Task{ +def compile = Task { os.call( ( npmInstall().path / "node_modules/typescript/bin/tsc", allSources().map(_.path), - "--outDir", Task.dest, - "--typeRoots", npmInstall().path / "node_modules/@types" + "--outDir", + Task.dest, + "--typeRoots", + npmInstall().path / "node_modules/@types" ) ) PathRef(Task.dest) @@ -106,8 +107,8 @@ console.log("Hello " + user.firstName + " " + user.lastName); // as the program entrypoint, and a `run` command taking arguments that get used to // call `node` along with the main Javascript file: -def mainFileName = Task{ "hello.js" } -def run(args: mill.define.Args) = Task.Command{ +def mainFileName = Task { "hello.js" } +def run(args: mill.define.Args) = Task.Command { os.call( ("node", compile().path / mainFileName(), args.value), stdout = os.Inherit @@ -136,4 +137,4 @@ Hello James Bond // So that's a minimal example of implementing a single TypeScript to JavaScript build // pipeline locally. Next, we will look at turning it into a `TypeScriptModule` that -// can be re-used \ No newline at end of file +// can be re-used diff --git a/example/extending/newlang/2-typescript-modules/build.mill b/example/extending/newlang/2-typescript-modules/build.mill index 2e7c4bf4ce9..aae72e2627f 100644 --- a/example/extending/newlang/2-typescript-modules/build.mill +++ b/example/extending/newlang/2-typescript-modules/build.mill @@ -7,26 +7,26 @@ package build import mill._ -trait TypeScriptModule extends Module{ - def npmInstall = Task{ +trait TypeScriptModule extends Module { + def npmInstall = Task { os.call(("npm", "install", "--save-dev", "typescript@5.6.3", "@types/node@22.7.8")) PathRef(Task.dest) } def sources = Task.Source(millSourcePath / "src") - def allSources = Task{ + def allSources = Task { os.walk(sources().path).filter(_.ext == "ts").map(PathRef(_)) } - def compile = Task{ + def compile = Task { val tsc = npmInstall().path / "node_modules/typescript/bin/tsc" val types = npmInstall().path / "node_modules/@types" os.call((tsc, allSources().map(_.path), "--outDir", Task.dest, "--typeRoots", types)) PathRef(Task.dest) } - def mainFileName = Task{ s"${millSourcePath.last}.js" } - def run(args: mill.define.Args) = Task.Command{ + def mainFileName = Task { s"${millSourcePath.last}.js" } + def run(args: mill.define.Args) = Task.Command { val mainFile = compile().path / mainFileName() os.call(("node", mainFile, args.value), stdout = os.Inherit) } @@ -35,7 +35,7 @@ trait TypeScriptModule extends Module{ // We can then instantiate the module three times. Module can be adjacent or nested, // as shown belo: -object foo extends TypeScriptModule{ +object foo extends TypeScriptModule { object bar extends TypeScriptModule } object qux extends TypeScriptModule @@ -90,4 +90,4 @@ Hello James Qux // ``` // // Next, we will look at how to wire them up using -// `moduleDeps`. \ No newline at end of file +// `moduleDeps`. diff --git a/example/extending/newlang/3-module-deps/build.mill b/example/extending/newlang/3-module-deps/build.mill index 6321582d40c..5d8bdb56bd3 100644 --- a/example/extending/newlang/3-module-deps/build.mill +++ b/example/extending/newlang/3-module-deps/build.mill @@ -14,25 +14,25 @@ package build import mill._ -trait TypeScriptModule extends Module{ +trait TypeScriptModule extends Module { def moduleDeps: Seq[TypeScriptModule] = Nil - def npmInstall = Task{ + def npmInstall = Task { os.call(("npm", "install", "--save-dev", "typescript@5.6.3", "@types/node@22.7.8")) PathRef(Task.dest) } def sources = Task.Source(millSourcePath / "src") - def allSources = Task{ os.walk(sources().path).filter(_.ext == "ts").map(PathRef(_)) } + def allSources = Task { os.walk(sources().path).filter(_.ext == "ts").map(PathRef(_)) } - def compile: T[(PathRef, PathRef)] = Task{ + def compile: T[(PathRef, PathRef)] = Task { val nodeTypes = npmInstall().path / "node_modules/@types" val javascriptOut = Task.dest / "javascript" val declarationsOut = Task.dest / "declarations" val upstreamPaths = - for(((jsDir, dTsDir), mod) <- Task.traverse(moduleDeps)(_.compile)().zip(moduleDeps)) + for (((jsDir, dTsDir), mod) <- Task.traverse(moduleDeps)(_.compile)().zip(moduleDeps)) yield (mod.millSourcePath.subRelativeTo(build.millSourcePath) + "/*", dTsDir.path) val allPaths = upstreamPaths ++ Seq("*" -> sources().path) @@ -45,9 +45,9 @@ trait TypeScriptModule extends Module{ "declaration" -> true, "declarationDir" -> declarationsOut.toString, "typeRoots" -> ujson.Arr(nodeTypes.toString), - "paths" -> ujson.Obj.from(allPaths.map{case (k, v) => (k, ujson.Arr(s"$v/*"))}) + "paths" -> ujson.Obj.from(allPaths.map { case (k, v) => (k, ujson.Arr(s"$v/*")) }) ), - "files" -> allSources().map(_.path.toString), + "files" -> allSources().map(_.path.toString) ) ) @@ -55,11 +55,11 @@ trait TypeScriptModule extends Module{ (PathRef(javascriptOut), PathRef(declarationsOut)) } - def mainFileName = Task{ s"${millSourcePath.last}.js" } - def run(args: mill.define.Args) = Task.Command{ + def mainFileName = Task { s"${millSourcePath.last}.js" } + def run(args: mill.define.Args) = Task.Command { val upstream = Task.traverse(moduleDeps)(_.compile)().zip(moduleDeps) - for(((jsDir, tTsDir), mod) <- upstream) { + for (((jsDir, tTsDir), mod) <- upstream) { os.copy(jsDir.path, Task.dest / mod.millSourcePath.subRelativeTo(build.millSourcePath)) } val mainFile = compile()._1.path / mainFileName() @@ -79,10 +79,10 @@ trait TypeScriptModule extends Module{ // Again, we can instantiate `TypeScriptModule` three times, but now `foo/src/foo.ts` // and `foo/bar/src/bar.ts` export their APIs which are then imported in `qux/src/qux.ts`: -object foo extends TypeScriptModule{ +object foo extends TypeScriptModule { object bar extends TypeScriptModule } -object qux extends TypeScriptModule{ +object qux extends TypeScriptModule { def moduleDeps = Seq(foo, foo.bar) } @@ -131,4 +131,4 @@ Hello James Bond Professor // "bar.compile" -> "qux.compile" [color=green, penwidth=3] // "foo.compile" -> "qux.compile" [color=green, penwidth=3] // } -// ``` \ No newline at end of file +// ``` diff --git a/example/extending/newlang/4-npm-deps-bundle/build.mill b/example/extending/newlang/4-npm-deps-bundle/build.mill index 4aa9a9314b5..d276c659e8f 100644 --- a/example/extending/newlang/4-npm-deps-bundle/build.mill +++ b/example/extending/newlang/4-npm-deps-bundle/build.mill @@ -17,34 +17,38 @@ package build import mill._ -trait TypeScriptModule extends Module{ +trait TypeScriptModule extends Module { def moduleDeps: Seq[TypeScriptModule] = Nil - def npmDeps: T[Seq[String]] = Task{ Seq.empty[String] } + def npmDeps: T[Seq[String]] = Task { Seq.empty[String] } - def transitiveNpmDeps: T[Seq[String]] = Task{ + def transitiveNpmDeps: T[Seq[String]] = Task { Task.traverse(moduleDeps)(_.npmDeps)().flatten ++ npmDeps() } - def npmInstall = Task{ + def npmInstall = Task { os.call(( - "npm", "install", "--save-dev", - "typescript@5.6.3", "@types/node@22.7.8", "esbuild@0.24.0", + "npm", + "install", + "--save-dev", + "typescript@5.6.3", + "@types/node@22.7.8", + "esbuild@0.24.0", transitiveNpmDeps() )) PathRef(Task.dest) } def sources = Task.Source(millSourcePath / "src") - def allSources = Task{ os.walk(sources().path).filter(_.ext == "ts").map(PathRef(_)) } + def allSources = Task { os.walk(sources().path).filter(_.ext == "ts").map(PathRef(_)) } - def compile: T[(PathRef, PathRef)] = Task{ + def compile: T[(PathRef, PathRef)] = Task { val nodeTypes = npmInstall().path / "node_modules/@types" val javascriptOut = Task.dest / "javascript" val declarationsOut = Task.dest / "declarations" val upstreamPaths = - for(((jsDir, dTsDir), mod) <- Task.traverse(moduleDeps)(_.compile)().zip(moduleDeps)) + for (((jsDir, dTsDir), mod) <- Task.traverse(moduleDeps)(_.compile)().zip(moduleDeps)) yield (mod.millSourcePath.subRelativeTo(build.millSourcePath) + "/*", dTsDir.path) val allPaths = upstreamPaths ++ Seq("*" -> sources().path, "*" -> npmInstall().path) @@ -57,9 +61,9 @@ trait TypeScriptModule extends Module{ "declaration" -> true, "declarationDir" -> declarationsOut.toString, "typeRoots" -> ujson.Arr(nodeTypes.toString), - "paths" -> ujson.Obj.from(allPaths.map{case (k, v) => (k, ujson.Arr(s"$v/*"))}) + "paths" -> ujson.Obj.from(allPaths.map { case (k, v) => (k, ujson.Arr(s"$v/*")) }) ), - "files" -> allSources().map(_.path.toString), + "files" -> allSources().map(_.path.toString) ) ) @@ -68,11 +72,11 @@ trait TypeScriptModule extends Module{ (PathRef(javascriptOut), PathRef(declarationsOut)) } - def mainFileName = Task{ s"${millSourcePath.last}.js" } + def mainFileName = Task { s"${millSourcePath.last}.js" } - def prepareRun = Task.Anon{ + def prepareRun = Task.Anon { val upstream = Task.traverse(moduleDeps)(_.compile)().zip(moduleDeps) - for(((jsDir, tTsDir), mod) <- upstream) { + for (((jsDir, tTsDir), mod) <- upstream) { os.copy(jsDir.path, Task.dest / mod.millSourcePath.subRelativeTo(build.millSourcePath)) } val mainFile = compile()._1.path / mainFileName() @@ -80,12 +84,12 @@ trait TypeScriptModule extends Module{ (mainFile, env) } - def run(args: mill.define.Args) = Task.Command{ + def run(args: mill.define.Args) = Task.Command { val (mainFile, env) = prepareRun() os.call(("node", mainFile, args.value), stdout = os.Inherit, env = env) } - def bundle = Task{ + def bundle = Task { val (mainFile, env) = prepareRun() val esbuild = npmInstall().path / "node_modules/esbuild/bin/esbuild" val bundle = Task.dest / "bundle.js" @@ -94,16 +98,15 @@ trait TypeScriptModule extends Module{ } } -object foo extends TypeScriptModule{ - object bar extends TypeScriptModule{ +object foo extends TypeScriptModule { + object bar extends TypeScriptModule { def npmDeps = Seq("immutable@4.3.7") } } -object qux extends TypeScriptModule{ +object qux extends TypeScriptModule { def moduleDeps = Seq(foo, foo.bar) } - // We can now not only invoke the `qux.run` to run the `TypeScriptModule` immediately // using `node`, we can also use `qux.bundle` to generate a `bundle.js` file we can run // standalone using `node`: @@ -169,4 +172,4 @@ Hello James Bond Professor // "foo.npmDeps" -> "qux.npmDeps" [color=green, penwidth=3] // "bar.npmDeps" -> "qux.npmDeps" [color=green, penwidth=3] // } -// ``` \ No newline at end of file +// ``` diff --git a/example/extending/plugins/7-writing-mill-plugins/build.mill b/example/extending/plugins/7-writing-mill-plugins/build.mill index c18ba92bb62..a0f8bf8df58 100644 --- a/example/extending/plugins/7-writing-mill-plugins/build.mill +++ b/example/extending/plugins/7-writing-mill-plugins/build.mill @@ -17,12 +17,12 @@ object myplugin extends ScalaModule with PublishModule { def ivyDeps = Agg(ivy"com.lihaoyi:mill-dist:$millVersion") // Testing Config, with necessary setup for unit/integration/example tests - object test extends ScalaTests with TestModule.Utest{ + object test extends ScalaTests with TestModule.Utest { def ivyDeps = Agg(ivy"com.lihaoyi::mill-testkit:$millVersion") def forkEnv = Map("MILL_EXECUTABLE_PATH" -> millExecutable.assembly().path.toString) // Create a Mill executable configured for testing our plugin - object millExecutable extends JavaModule{ + object millExecutable extends JavaModule { def ivyDeps = Agg(ivy"com.lihaoyi:mill-dist:$millVersion") def mainClass = Some("mill.runner.client.MillClientMain") def resources = Task { @@ -53,7 +53,7 @@ object myplugin extends ScalaModule with PublishModule { // // The above `build.mill` file sets up a `object myplugin extends ScalaModule` not just to // compile your Mill plugin project, but also to run automated tests using `mill-testkit`, -// and to configure it for publishing to Maven Central via `PublishModule`. +// and to configure it for publishing to Maven Central via `PublishModule`. // It looks like any other Scala project, except for a few things to take note: // // * We set the `platformSuffix` to indicate which Mill binary API version @@ -65,7 +65,6 @@ object myplugin extends ScalaModule with PublishModule { // assembly to configure it to rewire `import $ivy` to instead use the local compiled // classfiles for testing. - // == Plugin Implementation // Although Mill plugins can contain arbitrary code, the most common @@ -94,7 +93,6 @@ compiling 1 Scala source... */ - // Mill provides the `mill-testkit` library to make it easy for you to test your Mill // plugin. The example project above has set up tests that can be run via the normal `.test` // command, as shown below: @@ -205,4 +203,3 @@ Publishing Artifact(com.lihaoyi,myplugin_mill0.11_2.13,0.0.2) to ivy repo... // or to Maven Central via `mill.scalalib.public.PublishModule/` for other developers to // use. For more details on publishing Mill projects, see the documentation for // xref:scalalib/publishing.adoc[Publishing Scala Projects] - diff --git a/example/extending/plugins/7-writing-mill-plugins/myplugin/src/LineCountJavaModule.scala b/example/extending/plugins/7-writing-mill-plugins/myplugin/src/LineCountJavaModule.scala index fc08a76a92a..86e5ac28871 100644 --- a/example/extending/plugins/7-writing-mill-plugins/myplugin/src/LineCountJavaModule.scala +++ b/example/extending/plugins/7-writing-mill-plugins/myplugin/src/LineCountJavaModule.scala @@ -1,10 +1,12 @@ package myplugin import mill._ + /** * Example Mill plugin trait that adds a `line-count.txt` * to the resources of your `JavaModule` */ -trait LineCountJavaModule extends mill.javalib.JavaModule{ +trait LineCountJavaModule extends mill.javalib.JavaModule { + /** Name of the file containing the line count that we create in the resource path */ def lineCountResourceFileName: T[String] diff --git a/example/extending/plugins/7-writing-mill-plugins/myplugin/test/resources/example-test-project/build.mill b/example/extending/plugins/7-writing-mill-plugins/myplugin/test/resources/example-test-project/build.mill index 0acaea4ee0e..03147287731 100644 --- a/example/extending/plugins/7-writing-mill-plugins/myplugin/test/resources/example-test-project/build.mill +++ b/example/extending/plugins/7-writing-mill-plugins/myplugin/test/resources/example-test-project/build.mill @@ -2,7 +2,7 @@ package build import $ivy.`com.lihaoyi::myplugin::0.0.1` import mill._, myplugin._ -object `package` extends RootModule with LineCountJavaModule{ +object `package` extends RootModule with LineCountJavaModule { def lineCountResourceFileName = "line-count.txt" } @@ -18,4 +18,4 @@ Line Count: 17 Line Count: 18 ... -*/ \ No newline at end of file +*/ diff --git a/example/extending/plugins/7-writing-mill-plugins/myplugin/test/resources/integration-test-project/build.mill b/example/extending/plugins/7-writing-mill-plugins/myplugin/test/resources/integration-test-project/build.mill index 0c61e9288a2..97ba5593b3d 100644 --- a/example/extending/plugins/7-writing-mill-plugins/myplugin/test/resources/integration-test-project/build.mill +++ b/example/extending/plugins/7-writing-mill-plugins/myplugin/test/resources/integration-test-project/build.mill @@ -2,7 +2,6 @@ package build import $ivy.`com.lihaoyi::myplugin::0.0.1` import mill._, myplugin._ -object `package` extends RootModule with LineCountJavaModule{ +object `package` extends RootModule with LineCountJavaModule { def lineCountResourceFileName = "line-count.txt" } - diff --git a/example/extending/plugins/7-writing-mill-plugins/myplugin/test/src/mill/testkit/UnitTests.scala b/example/extending/plugins/7-writing-mill-plugins/myplugin/test/src/mill/testkit/UnitTests.scala index 44e5ab6045e..ee81ba3d432 100644 --- a/example/extending/plugins/7-writing-mill-plugins/myplugin/test/src/mill/testkit/UnitTests.scala +++ b/example/extending/plugins/7-writing-mill-plugins/myplugin/test/src/mill/testkit/UnitTests.scala @@ -12,7 +12,6 @@ object UnitTests extends TestSuite { val resourceFolder = os.Path(sys.env("MILL_TEST_RESOURCE_DIR")) UnitTester(build, resourceFolder / "unit-test-project").scoped { eval => - // Evaluating tasks by direct reference val Right(result) = eval(build.resources) assert( diff --git a/example/fundamentals/cross/10-static-blog/build.mill b/example/fundamentals/cross/10-static-blog/build.mill index c32ac8a8cf1..e4c07e00321 100644 --- a/example/fundamentals/cross/10-static-blog/build.mill +++ b/example/fundamentals/cross/10-static-blog/build.mill @@ -25,7 +25,7 @@ val posts = interp.watchValue { } object post extends Cross[PostModule](posts) -trait PostModule extends Cross.Module[String]{ +trait PostModule extends Cross.Module[String] { def source = Task.Source(millSourcePath / crossValue) def render = Task { val doc = Parser.builder().build().parse(os.read(source().path)) @@ -39,7 +39,7 @@ trait PostModule extends Cross.Module[String]{ ) ) - os.write(Task.dest / mdNameToHtml(crossValue), rendered) + os.write(Task.dest / mdNameToHtml(crossValue), rendered) PathRef(Task.dest / mdNameToHtml(crossValue)) } } @@ -50,7 +50,7 @@ trait PostModule extends Cross.Module[String]{ // what `os.list` finds on disk. After that, it's straightforward to render the // `index.html` file we want: -def postsInput = Task.Input{ posts } +def postsInput = Task.Input { posts } def renderIndexEntry(mdName: String) = { h2(a(mdNameToTitle(mdName), href := ("post/" + mdNameToHtml(mdName)))) @@ -137,4 +137,4 @@ def dist = Task { // This example use case is taken from the following blog post, which contains // some extensions and fun exercises to further familiarize yourself with Mill // -// * http://www.lihaoyi.com/post/HowtocreateBuildPipelinesinScala.html[How to create Build Pipelines in Scala] \ No newline at end of file +// * http://www.lihaoyi.com/post/HowtocreateBuildPipelinesinScala.html[How to create Build Pipelines in Scala] diff --git a/example/fundamentals/cross/11-default-cross-module/build.mill b/example/fundamentals/cross/11-default-cross-module/build.mill index 1457be69583..fcb3fe14e3a 100644 --- a/example/fundamentals/cross/11-default-cross-module/build.mill +++ b/example/fundamentals/cross/11-default-cross-module/build.mill @@ -11,7 +11,6 @@ object bar extends Cross[FooModule]("2.10", "2.11", "2.12") { def defaultCrossSegments = Seq("2.12") } - // For convenience, you can omit the selector for the default cross segment. // By default, this is the first cross value specified, but you can override // it by specifying `def defaultCrossSegments` @@ -28,5 +27,3 @@ object bar extends Cross[FooModule]("2.10", "2.11", "2.12") { "_2.12" */ - - diff --git a/example/fundamentals/cross/2-cross-source-path/build.mill b/example/fundamentals/cross/2-cross-source-path/build.mill index 8ff8c5ddc36..3996e9d29df 100644 --- a/example/fundamentals/cross/2-cross-source-path/build.mill +++ b/example/fundamentals/cross/2-cross-source-path/build.mill @@ -42,4 +42,4 @@ trait FooModule extends Cross.Module[String] { // ---- // def millSourcePath = super.millSourcePath / os.up // ---- -// -- \ No newline at end of file +// -- diff --git a/example/fundamentals/cross/3-outside-dependency/build.mill b/example/fundamentals/cross/3-outside-dependency/build.mill index 9ed5d524274..6d8fa678c04 100644 --- a/example/fundamentals/cross/3-outside-dependency/build.mill +++ b/example/fundamentals/cross/3-outside-dependency/build.mill @@ -39,7 +39,6 @@ def qux = Task { s"hello ${foo("2.10").suffix()} world ${foo("2.12").suffix()}" // } // ``` - // Here, `def bar` uses `foo("2.10")` to reference the `"2.10"` instance of // `FooModule`. You can refer to whatever versions of the cross-module you want, // even using multiple versions of the cross-module in the same task as we do @@ -56,4 +55,4 @@ def qux = Task { s"hello ${foo("2.10").suffix()} world ${foo("2.12").suffix()}" > mill show qux "hello _2.10 world _2.12" -*/ \ No newline at end of file +*/ diff --git a/example/fundamentals/cross/4-cross-dependencies/build.mill b/example/fundamentals/cross/4-cross-dependencies/build.mill index 16a12a43d2c..0979e2c90c8 100644 --- a/example/fundamentals/cross/4-cross-dependencies/build.mill +++ b/example/fundamentals/cross/4-cross-dependencies/build.mill @@ -75,4 +75,4 @@ trait BarModule extends Cross.Module[String] { "bar[2.12].bigSuffix": "[[[_2.12]]]" } -*/ \ No newline at end of file +*/ diff --git a/example/fundamentals/cross/5-multiple-cross-axes/build.mill b/example/fundamentals/cross/5-multiple-cross-axes/build.mill index dcaeeee6a5d..e5027aee2ae 100644 --- a/example/fundamentals/cross/5-multiple-cross-axes/build.mill +++ b/example/fundamentals/cross/5-multiple-cross-axes/build.mill @@ -91,4 +91,4 @@ def bar = Task { s"hello ${foo("2.10", "jvm").suffix()}" } "foo[2.12,native].suffix": "_2.12_native" } -*/ \ No newline at end of file +*/ diff --git a/example/fundamentals/cross/6-axes-extension/build.mill b/example/fundamentals/cross/6-axes-extension/build.mill index 6235d28956c..438352243cf 100644 --- a/example/fundamentals/cross/6-axes-extension/build.mill +++ b/example/fundamentals/cross/6-axes-extension/build.mill @@ -58,4 +58,4 @@ trait FooModule3 extends FooModule2 with Cross.Module3[String, Int, Boolean] { error: ...object foo3 extends Cross[FooModule3](("a", 1), ("b", 2)) error: ... ^ error: ...value _3 is not a member of (String, Int) -*/ \ No newline at end of file +*/ diff --git a/example/fundamentals/cross/7-inner-cross-module/build.mill b/example/fundamentals/cross/7-inner-cross-module/build.mill index ae9afaab96a..84096113f3f 100644 --- a/example/fundamentals/cross/7-inner-cross-module/build.mill +++ b/example/fundamentals/cross/7-inner-cross-module/build.mill @@ -1,7 +1,7 @@ package build import mill._ -trait MyModule extends Module{ +trait MyModule extends Module { def crossValue: String def name: T[String] def param = Task { name() + " Param Value: " + crossValue } @@ -9,10 +9,10 @@ trait MyModule extends Module{ object foo extends Cross[FooModule]("a", "b") trait FooModule extends Cross.Module[String] { - object bar extends MyModule with CrossValue{ + object bar extends MyModule with CrossValue { def name = "Bar" } - object qux extends MyModule with CrossValue{ + object qux extends MyModule with CrossValue { def name = "Qux" } } @@ -69,4 +69,4 @@ def baz = Task { s"hello ${foo("a").bar.param()}" } > mill show baz "hello Bar Param Value: a" -*/ \ No newline at end of file +*/ diff --git a/example/fundamentals/cross/8-resolvers/build.mill b/example/fundamentals/cross/8-resolvers/build.mill index 6418ced46ad..e36f6cdc30a 100644 --- a/example/fundamentals/cross/8-resolvers/build.mill +++ b/example/fundamentals/cross/8-resolvers/build.mill @@ -65,4 +65,4 @@ trait BarModule extends MyModule { // │ ├── bigSuffix.json // │ └── suffix.json // ---- -// \ No newline at end of file +// diff --git a/example/fundamentals/cross/9-dynamic-cross-modules/build.mill b/example/fundamentals/cross/9-dynamic-cross-modules/build.mill index 5b5eae94bbe..a1f6147c72f 100644 --- a/example/fundamentals/cross/9-dynamic-cross-modules/build.mill +++ b/example/fundamentals/cross/9-dynamic-cross-modules/build.mill @@ -4,7 +4,7 @@ import mill._, scalalib._ val moduleNames = interp.watchValue(os.list(millSourcePath / "modules").map(_.last)) object modules extends Cross[FolderModule](moduleNames) -trait FolderModule extends ScalaModule with Cross.Module[String]{ +trait FolderModule extends ScalaModule with Cross.Module[String] { def millSourcePath = super.millSourcePath / crossValue def scalaVersion = "2.13.8" } @@ -50,4 +50,4 @@ Hello World New // Note that because the inputs to the `Cross` constructor affects the number // of cross-modules that are generated, it has to be a raw value e.g. // `List[T]` and not a task `T[List[T]]`. That also means that the list of -// cross-modules cannot depend on the output of any tasks. \ No newline at end of file +// cross-modules cannot depend on the output of any tasks. diff --git a/example/fundamentals/dependencies/1-search-updates/build.mill b/example/fundamentals/dependencies/1-search-updates/build.mill index 22cb7f31046..6477fef2a4c 100644 --- a/example/fundamentals/dependencies/1-search-updates/build.mill +++ b/example/fundamentals/dependencies/1-search-updates/build.mill @@ -1,4 +1,3 @@ - // Mill can search for updated versions of your project's dependencies, if // available from your project's configured repositories. Note that it uses // heuristics based on common versioning schemes, so it may not work as expected for @@ -37,4 +36,4 @@ object bar extends MyModule { // ``CrossScalaModule``s, etc.) and Maven repositories. // * Always applies to all modules in the build. // * Doesn't apply to `$ivy` dependencies used in the build definition itself. -// \ No newline at end of file +// diff --git a/example/fundamentals/libraries/1-oslib/build.mill b/example/fundamentals/libraries/1-oslib/build.mill index d97155e7900..d4aab47f3cd 100644 --- a/example/fundamentals/libraries/1-oslib/build.mill +++ b/example/fundamentals/libraries/1-oslib/build.mill @@ -40,4 +40,4 @@ hello .../out/task2.dest/file.txt world -*/ \ No newline at end of file +*/ diff --git a/example/fundamentals/libraries/2-upickle/build.mill b/example/fundamentals/libraries/2-upickle/build.mill index b99b26b5e7d..cb5889953f4 100644 --- a/example/fundamentals/libraries/2-upickle/build.mill +++ b/example/fundamentals/libraries/2-upickle/build.mill @@ -23,7 +23,6 @@ def taskInt = Task { 123 } def taskBoolean = Task { true } def taskString = Task { "hello " + taskInt() + " world " + taskBoolean() } - /** Usage > ./mill show taskInt @@ -43,11 +42,10 @@ true ] */ -def taskTuple = Task { (taskInt(), taskBoolean(), taskString())} -def taskSeq = Task { Seq(taskInt(), taskInt() * 2, taskInt() * 3)} +def taskTuple = Task { (taskInt(), taskBoolean(), taskString()) } +def taskSeq = Task { Seq(taskInt(), taskInt() * 2, taskInt() * 3) } def taskMap = Task { Map("int" -> taskInt().toString, "boolean" -> taskBoolean().toString) } - /** Usage > ./mill show taskSeq [ diff --git a/example/fundamentals/libraries/4-mainargs/build.mill b/example/fundamentals/libraries/4-mainargs/build.mill index aa65a89c7bd..9a7add22f9a 100644 --- a/example/fundamentals/libraries/4-mainargs/build.mill +++ b/example/fundamentals/libraries/4-mainargs/build.mill @@ -2,7 +2,7 @@ // are run from the command line. import mill._ -def commandSimple(str: String, i: Int, bool: Boolean = true) = Task.Command{ +def commandSimple(str: String, i: Int, bool: Boolean = true) = Task.Command { println(s"$str $i $bool") } @@ -19,14 +19,12 @@ hello 123 true */ - // === `os.Path` // // In addition to the builtin set of types that MainArgs supports, Mill also // supports parsing OS-Lib ``os.Path``s from the command line: - -def commandTakingPath(path: os.Path) = Task.Command{ +def commandTakingPath(path: os.Path) = Task.Command { println(path) } @@ -44,7 +42,7 @@ def commandTakingPath(path: os.Path) = Task.Command{ // command as part of another task, while passing it the value of an upstream // task: -def commandTakingTask(str: Task[String]) = Task.Command{ +def commandTakingTask(str: Task[String]) = Task.Command { val result = "arg: " + str() println(result) result @@ -65,7 +63,6 @@ def taskCallingCommand = Task { commandTakingTask(upstreamTask)() } - /** Usage > ./mill show taskCallingCommand @@ -73,7 +70,6 @@ def taskCallingCommand = Task { */ - // === Evaluator (experimental) // // _Evaluator Command are experimental and suspected to change. @@ -92,7 +88,7 @@ def customPlanCommand(evaluator: Evaluator, tasks: String*) = Task.Command { evaluator.rootModule, tasks, SelectMode.Multi - ) match{ + ) match { case Left(err) => Left(err) case Right(resolved) => val (sortedGroups, _) = evaluator.plan(resolved) diff --git a/example/fundamentals/modules/11-abstract-module-ref/build.mill b/example/fundamentals/modules/11-abstract-module-ref/build.mill index d0a04682862..f9d5cc8b027 100644 --- a/example/fundamentals/modules/11-abstract-module-ref/build.mill +++ b/example/fundamentals/modules/11-abstract-module-ref/build.mill @@ -12,20 +12,19 @@ import mill.define.ModuleRef object foo extends JavaModule object bar extends JavaModule -trait MyTestModule extends JavaModule with TestModule.Junit4{ +trait MyTestModule extends JavaModule with TestModule.Junit4 { def upstreamModule: ModuleRef[JavaModule] def moduleDeps = Seq(upstreamModule()) } -object footest extends MyTestModule{ +object footest extends MyTestModule { def upstreamModule = ModuleRef(foo) } -object bartest extends MyTestModule{ +object bartest extends MyTestModule { def upstreamModule = ModuleRef(bar) } - /** Usage > mill __.test diff --git a/example/fundamentals/modules/6-modules/build.mill b/example/fundamentals/modules/6-modules/build.mill index 359027f5b18..5469c0cd5b8 100644 --- a/example/fundamentals/modules/6-modules/build.mill +++ b/example/fundamentals/modules/6-modules/build.mill @@ -63,7 +63,7 @@ trait FooModule extends Module { def qux = Task { bar() + " world" } } -object foo1 extends FooModule{ +object foo1 extends FooModule { def bar = "hello" def qux = super.qux().toUpperCase // refer to overriden value via super } @@ -115,7 +115,6 @@ object foo2 extends FooModule { */ - // The built-in `mill.scalalib` package uses this to define `ScalaModule`, // `SbtModule` and `TestScalaModule`, etc. which contain a set of "standard" // operations such as `compile`, `jar` or `assembly` that you may expect from a @@ -129,7 +128,7 @@ object foo2 extends FooModule { // Each Module has a `millSourcePath` field that corresponds to the path that // module expects its input files to be on disk. -trait MyModule extends Module{ +trait MyModule extends Module { def sources = Task.Source(millSourcePath / "sources") def task = Task { "hello " + os.list(sources().path).map(os.read(_)).mkString(" ") } } @@ -223,4 +222,4 @@ object outer2 extends MyModule { // paths defined are relative to the module's root folder, so the module logic can continue // to work even if moved into a different subfolder. In the rare case where you need the // Mill project root path, and you truly know what you are doing, you can call -// g`mill.api.WorkspaceRoot.workspaceRoot`. \ No newline at end of file +// g`mill.api.WorkspaceRoot.workspaceRoot`. diff --git a/example/fundamentals/modules/7-root-module/build.mill b/example/fundamentals/modules/7-root-module/build.mill index dd0aa69bdeb..a8b99b17379 100644 --- a/example/fundamentals/modules/7-root-module/build.mill +++ b/example/fundamentals/modules/7-root-module/build.mill @@ -10,7 +10,7 @@ object `package` extends RootModule with JavaModule { ivy"org.thymeleaf:thymeleaf:3.1.1.RELEASE" ) - object test extends JavaTests with TestModule.Junit4{ + object test extends JavaTests with TestModule.Junit4 { def ivyDeps = super.ivyDeps() ++ Agg( ivy"com.google.guava:guava:33.3.0-jre" ) @@ -67,4 +67,3 @@ Test run foo.FooTest finished: 0 failed, 0 ignored, 2 total, ... // a `build.mill` or `package.mill` file. If a `RootModule` is defined, all other // tasks or modules in that file must be defined within it, as it is the root of the // module hierarchy. - diff --git a/example/fundamentals/modules/8-diy-java-modules/build.mill b/example/fundamentals/modules/8-diy-java-modules/build.mill index 2b8eaa18846..678dd913b0f 100644 --- a/example/fundamentals/modules/8-diy-java-modules/build.mill +++ b/example/fundamentals/modules/8-diy-java-modules/build.mill @@ -4,7 +4,7 @@ package build import mill._ -trait DiyJavaModule extends Module{ +trait DiyJavaModule extends Module { def moduleDeps: Seq[DiyJavaModule] = Nil def mainClass: T[Option[String]] = None @@ -21,7 +21,7 @@ trait DiyJavaModule extends Module{ def classPath = Task { Seq(compile()) ++ upstream() } def assembly = Task { - for(cp <- classPath()) os.copy(cp.path, Task.dest, mergeFolders = true) + for (cp <- classPath()) os.copy(cp.path, Task.dest, mergeFolders = true) val mainFlags = mainClass().toSeq.flatMap(Seq("-e", _)) os.proc("jar", "-c", mainFlags, "-f", Task.dest / "assembly.jar", ".") @@ -163,4 +163,3 @@ Bar.value: 271828 // complicated to provide additional flexibility and performance. Nevertheless, // this example should give you a good idea of how Mill ``module``s can be // developed, so you can define your own custom modules when the need arises. - diff --git a/example/fundamentals/modules/9-backticked-names/build.mill b/example/fundamentals/modules/9-backticked-names/build.mill index 290487e0bb9..50e8cb10dfc 100644 --- a/example/fundamentals/modules/9-backticked-names/build.mill +++ b/example/fundamentals/modules/9-backticked-names/build.mill @@ -33,4 +33,4 @@ hyphenated task in a hyphenated module. > ./mill unhyphenatedModule.unhyphenated_task unhyphenated task in an unhyphenated module. -*/ \ No newline at end of file +*/ diff --git a/example/fundamentals/out-dir/1-custom-out/build.mill b/example/fundamentals/out-dir/1-custom-out/build.mill index fe36a067883..84d2b9f681f 100644 --- a/example/fundamentals/out-dir/1-custom-out/build.mill +++ b/example/fundamentals/out-dir/1-custom-out/build.mill @@ -13,7 +13,6 @@ object foo extends Module { } } - /** Usage > MILL_OUTPUT_DIR=build-stuff/working-dir ./mill foo.printDest ... diff --git a/example/fundamentals/tasks/1-task-graph/build.mill b/example/fundamentals/tasks/1-task-graph/build.mill index f4ac7245611..36469e0d00f 100644 --- a/example/fundamentals/tasks/1-task-graph/build.mill +++ b/example/fundamentals/tasks/1-task-graph/build.mill @@ -16,7 +16,7 @@ def compile = Task { } def assembly = Task { - for(p <- Seq(compile(), resources())) os.copy(p.path, Task.dest, mergeFolders = true) + for (p <- Seq(compile(), resources())) os.copy(p.path, Task.dest, mergeFolders = true) val mainFlags = mainClass().toSeq.flatMap(Seq("-e", _)) os.proc("jar", "-c", mainFlags, "-f", Task.dest / "assembly.jar", ".") @@ -99,4 +99,4 @@ My Example Text // mainClass [fillcolor=lightgreen] // } // ``` -// \ No newline at end of file +// diff --git a/example/fundamentals/tasks/2-primary-tasks/build.mill b/example/fundamentals/tasks/2-primary-tasks/build.mill index 0e4e80ca7ef..2b1c8934b08 100644 --- a/example/fundamentals/tasks/2-primary-tasks/build.mill +++ b/example/fundamentals/tasks/2-primary-tasks/build.mill @@ -12,7 +12,6 @@ import mill.{Module, T, _} def sources = Task.Source { millSourcePath / "src" } def resources = Task.Source { millSourcePath / "resources" } - // ``Source``s are defined using `Task.Source{...}` taking one `os.Path`, or `Task.Sources{...}`, // taking multiple ``os.Path``s as arguments. A ``Source``'s: // its build signature/`hashCode` depends not just on the path @@ -209,7 +208,6 @@ def hugeFileName = Task { // in `def largeFile` above running even though the `largeFile()` branch of the // `if` conditional does not get used: - /** Usage > ./mill show lineCount @@ -262,7 +260,6 @@ def summarizeClassFileStats = Task { */ - // For more details on how to use uPickle, check out the // https://github.com/com-lihaoyi/upickle[uPickle library documentation] // @@ -270,11 +267,12 @@ def summarizeClassFileStats = Task { def run(mainClass: String, args: String*) = Task.Command { os.proc( - "java", - "-cp", s"${classFiles().path}:${resources().path}", - mainClass, - args - ) + "java", + "-cp", + s"${classFiles().path}:${resources().path}", + mainClass, + args + ) .call(stdout = os.Inherit) } @@ -338,7 +336,6 @@ foo.txt resource: My Example Text */ - // // Like <<_cached_tasks>>, a command only evaluates after all its upstream // dependencies have completed, and will not begin to run if any upstream diff --git a/example/fundamentals/tasks/3-anonymous-tasks/build.mill b/example/fundamentals/tasks/3-anonymous-tasks/build.mill index 996a22dd164..9865068a524 100644 --- a/example/fundamentals/tasks/3-anonymous-tasks/build.mill +++ b/example/fundamentals/tasks/3-anonymous-tasks/build.mill @@ -21,13 +21,12 @@ def printFileData(fileName: String) = Task.Command { // Unlike <<_cached_tasks>> or <<_commands>>, anonymous tasks can be defined // anywhere and passed around any way you want, until you finally make use of them // within a downstream task or command. -// +// // While an anonymous task ``foo``'s own output is not cached, if it is used in a // downstream task `baz` and the upstream task `bar` hasn't changed, // ``baz``'s cached output will be used and ``foo``'s evaluation will be skipped // altogether. - /** Usage > ./mill show helloFileData diff --git a/example/fundamentals/tasks/4-inputs/build.mill b/example/fundamentals/tasks/4-inputs/build.mill index e6bba23f532..f6e9508059f 100644 --- a/example/fundamentals/tasks/4-inputs/build.mill +++ b/example/fundamentals/tasks/4-inputs/build.mill @@ -20,11 +20,11 @@ def myInput = Task.Input { def gitStatusTask = Task { "version-" + - os.proc("git", "log", "-1", "--pretty=format:%h-%B ") - .call(cwd = Task.workspace) - .out - .text() - .trim() + os.proc("git", "log", "-1", "--pretty=format:%h-%B ") + .call(cwd = Task.workspace) + .out + .text() + .trim() } /** Usage @@ -128,7 +128,6 @@ def myEnvTask = Task { "Hello Env " + myEnvInput() } - /** Usage > ./mill show myEnvTask diff --git a/example/fundamentals/tasks/5-persistent-tasks/build.mill b/example/fundamentals/tasks/5-persistent-tasks/build.mill index 5e2b94d7ffb..892bb8c0cff 100644 --- a/example/fundamentals/tasks/5-persistent-tasks/build.mill +++ b/example/fundamentals/tasks/5-persistent-tasks/build.mill @@ -23,7 +23,7 @@ def compressedData = Task(persistent = true) { os.makeDir.all(Task.dest / "cache") os.remove.all(Task.dest / "compressed") - for(p <- os.list(data().path)) { + for (p <- os.list(data().path)) { val compressedPath = Task.dest / "compressed" / s"${p.last}.gz" val bytes = os.read.bytes(p) val hash = Arrays.hashCode(bytes) diff --git a/example/fundamentals/tasks/6-workers/build.mill b/example/fundamentals/tasks/6-workers/build.mill index 059d6af938a..87d2889c937 100644 --- a/example/fundamentals/tasks/6-workers/build.mill +++ b/example/fundamentals/tasks/6-workers/build.mill @@ -13,11 +13,11 @@ import java.util.zip.GZIPOutputStream def data = Task.Source(millSourcePath / "data") -def compressWorker = Task.Worker{ new CompressWorker(Task.dest) } +def compressWorker = Task.Worker { new CompressWorker(Task.dest) } def compressedData = Task { println("Evaluating compressedData") - for(p <- os.list(data().path)){ + for (p <- os.list(data().path)) { os.write( Task.dest / s"${p.last}.gz", compressWorker().compress(p.last, os.read.bytes(p)) @@ -26,7 +26,7 @@ def compressedData = Task { os.list(Task.dest).map(PathRef(_)) } -class CompressWorker(dest: os.Path){ +class CompressWorker(dest: os.Path) { val cache = collection.mutable.Map.empty[Int, Array[Byte]] def compress(name: String, bytes: Array[Byte]): Array[Byte] = { val hash = Arrays.hashCode(bytes) @@ -36,11 +36,11 @@ class CompressWorker(dest: os.Path){ println("Compressing: " + name) cache(hash) = compressBytes(bytes) os.write(cachedPath, cache(hash)) - }else{ + } else { println("Cached from disk: " + name) cache(hash) = os.read.bytes(cachedPath) } - }else { + } else { println("Cached from memory: " + name) } cache(hash) diff --git a/example/fundamentals/tasks/7-forking-futures/build.mill b/example/fundamentals/tasks/7-forking-futures/build.mill index b2959c9315c..cf57aeb0921 100644 --- a/example/fundamentals/tasks/7-forking-futures/build.mill +++ b/example/fundamentals/tasks/7-forking-futures/build.mill @@ -8,14 +8,14 @@ package build import mill._ def taskSpawningFutures = Task { - val f1 = T.fork.async(dest = T.dest / "future-1", key = "1", message = "First Future"){ + val f1 = T.fork.async(dest = T.dest / "future-1", key = "1", message = "First Future") { println("Running First Future inside " + os.pwd) Thread.sleep(3000) val res = 1 println("Finished First Future") res } - val f2 = T.fork.async(dest = T.dest / "future-2", key = "2", message = "Second Future"){ + val f2 = T.fork.async(dest = T.dest / "future-2", key = "2", message = "Second Future") { println("Running Second Future inside " + os.pwd) Thread.sleep(3000) val res = 2 @@ -54,4 +54,4 @@ def taskSpawningFutures = Task { // While `scala.concurrent` and `java.util.concurrent` can also be used to spawn thread // pools and run async futures, `T.fork` provides a way to do so that integrates with Mill's // existing concurrency, sandboxing and logging systems. Thus you should always prefer to -// run async futures on `T.fork` whenever possible. \ No newline at end of file +// run async futures on `T.fork` whenever possible. diff --git a/example/javalib/web/1-hello-jetty/build.mill b/example/javalib/web/1-hello-jetty/build.mill index 6e258e63073..254d5a9f6e1 100644 --- a/example/javalib/web/1-hello-jetty/build.mill +++ b/example/javalib/web/1-hello-jetty/build.mill @@ -13,7 +13,6 @@ object `package` extends RootModule with JavaModule { // This example demonstrates how to set up a simple Jetty webserver, // able to handle a single HTTP request at `/` and reply with a single response. - /** Usage > mill test diff --git a/example/javalib/web/2-hello-spring-boot/build.mill b/example/javalib/web/2-hello-spring-boot/build.mill index 5e5dc343d92..952774fb2f1 100644 --- a/example/javalib/web/2-hello-spring-boot/build.mill +++ b/example/javalib/web/2-hello-spring-boot/build.mill @@ -17,7 +17,6 @@ object `package` extends RootModule with JavaModule { // This example demonstrates how to set up a simple Spring Boot webserver, // able to handle a single HTTP request at `/` and reply with a single response. - /** Usage > mill test diff --git a/example/javalib/web/3-todo-spring-boot/build.mill b/example/javalib/web/3-todo-spring-boot/build.mill index abc48c2b3d1..eb05f935708 100644 --- a/example/javalib/web/3-todo-spring-boot/build.mill +++ b/example/javalib/web/3-todo-spring-boot/build.mill @@ -10,19 +10,19 @@ object `package` extends RootModule with JavaModule { ivy"javax.xml.bind:jaxb-api:2.3.1", ivy"org.webjars:webjars-locator:0.41", ivy"org.webjars.npm:todomvc-common:1.0.5", - ivy"org.webjars.npm:todomvc-app-css:2.4.1", + ivy"org.webjars.npm:todomvc-app-css:2.4.1" ) - trait HelloTests extends JavaTests with TestModule.Junit5{ + trait HelloTests extends JavaTests with TestModule.Junit5 { def mainClass = Some("com.example.TodomvcApplication") def ivyDeps = super.ivyDeps() ++ Agg( ivy"org.springframework.boot:spring-boot-starter-test:2.5.6" ) } - object test extends HelloTests{ + object test extends HelloTests { def ivyDeps = super.ivyDeps() ++ Agg( - ivy"com.h2database:h2:2.3.230", + ivy"com.h2database:h2:2.3.230" ) } @@ -31,7 +31,7 @@ object `package` extends RootModule with JavaModule { ivy"org.testcontainers:testcontainers:1.18.0", ivy"org.testcontainers:junit-jupiter:1.18.0", ivy"org.testcontainers:postgresql:1.18.0", - ivy"org.postgresql:postgresql:42.6.0", + ivy"org.postgresql:postgresql:42.6.0" ) } } @@ -46,7 +46,6 @@ object `package` extends RootModule with JavaModule { // * Unit testing using a H2 in-memory database // * Integration testing using Testcontainers Postgres in Docker - /** Usage > mill test diff --git a/example/javalib/web/4-hello-micronaut/build.mill b/example/javalib/web/4-hello-micronaut/build.mill index fe5e399c88f..be2acd52e69 100644 --- a/example/javalib/web/4-hello-micronaut/build.mill +++ b/example/javalib/web/4-hello-micronaut/build.mill @@ -6,10 +6,10 @@ object `package` extends RootModule with MicronautModule { def ivyDeps = Agg( ivy"io.micronaut:micronaut-http-server-netty:$micronautVersion", ivy"io.micronaut.serde:micronaut-serde-jackson:2.10.1", - ivy"ch.qos.logback:logback-classic:1.5.3", + ivy"ch.qos.logback:logback-classic:1.5.3" ) - object test extends MavenTests with TestModule.Junit5{ + object test extends MavenTests with TestModule.Junit5 { def ivyDeps = super.ivyDeps() ++ Agg( ivy"io.micronaut:micronaut-http-client:$micronautVersion", ivy"io.micronaut.test:micronaut-test-junit5:4.4.0", @@ -19,7 +19,7 @@ object `package` extends RootModule with MicronautModule { } } -trait MicronautModule extends MavenModule{ +trait MicronautModule extends MavenModule { def micronautVersion: String def processors = Task { @@ -41,11 +41,10 @@ trait MicronautModule extends MavenModule{ "-Amicronaut.processing.incremental=true", "-Amicronaut.processing.group=example.micronaut", "-Amicronaut.processing.module=todo", - "-Amicronaut.processing.annotations=example.micronaut.*", + "-Amicronaut.processing.annotations=example.micronaut.*" ) } - // This example demonstrates how to set up a simple Micronaut example service, // using the code from the // https://guides.micronaut.io/latest/creating-your-first-micronaut-app.html[Micronaut Tutorial]. @@ -63,7 +62,6 @@ trait MicronautModule extends MavenModule{ // CLI; in particular, support for Micronaut AOT compilation is missing. But it easily can be // extended with more features as necessary. - /** Usage > mill test diff --git a/example/javalib/web/5-todo-micronaut/build.mill b/example/javalib/web/5-todo-micronaut/build.mill index ced57ffd803..4a38606f98c 100644 --- a/example/javalib/web/5-todo-micronaut/build.mill +++ b/example/javalib/web/5-todo-micronaut/build.mill @@ -5,7 +5,7 @@ object `package` extends RootModule with MicronautModule { def micronautVersion = "4.4.3" def runIvyDeps = Agg( ivy"ch.qos.logback:logback-classic:1.5.3", - ivy"com.h2database:h2:2.2.224", + ivy"com.h2database:h2:2.2.224" ) def ivyDeps = Agg( @@ -18,10 +18,10 @@ object `package` extends RootModule with MicronautModule { ivy"io.micronaut.views:micronaut-views-thymeleaf:5.2.0", ivy"org.webjars.npm:todomvc-common:1.0.5", ivy"org.webjars.npm:todomvc-app-css:2.4.1", - ivy"org.webjars.npm:github-com-bigskysoftware-htmx:1.9.10", + ivy"org.webjars.npm:github-com-bigskysoftware-htmx:1.9.10" ) - object test extends MavenTests with TestModule.Junit5{ + object test extends MavenTests with TestModule.Junit5 { def ivyDeps = super.ivyDeps() ++ Agg( ivy"com.h2database:h2:2.2.224", ivy"io.micronaut:micronaut-http-client:$micronautVersion", @@ -32,7 +32,7 @@ object `package` extends RootModule with MicronautModule { } } -trait MicronautModule extends MavenModule{ +trait MicronautModule extends MavenModule { def micronautVersion: String def processors = Task { @@ -54,11 +54,10 @@ trait MicronautModule extends MavenModule{ "-Amicronaut.processing.incremental=true", "-Amicronaut.processing.group=example.micronaut", "-Amicronaut.processing.module=todo", - "-Amicronaut.processing.annotations=example.micronaut.*", + "-Amicronaut.processing.annotations=example.micronaut.*" ) } - // This example is a more complete example using Micronaut, adapted from // https://github.com/sdelamo/todomvc. On top of the `MicronautModule` and // annotation processing demonstrated by the previous example, this example @@ -75,7 +74,6 @@ trait MicronautModule extends MavenModule{ // how Mill can be integrated with Micronaut's annotation processors and configuration, // and can be extended to cover additional functionality in future - /** Usage > mill test diff --git a/example/package.mill b/example/package.mill index 4ed7222057b..ddf3e856637 100644 --- a/example/package.mill +++ b/example/package.mill @@ -170,6 +170,7 @@ object `package` extends RootModule with Module { def fix(args: String*): Command[Unit] = T.command {} def testRepoRoot: T[PathRef] = T.source(millSourcePath) + def sources = Task.Sources { testRepoRoot().path } def resources = Seq(testRepoRoot()) def runClasspath = build.main.test.runClasspath() def localRunClasspath = build.testkit.localRunClasspath() diff --git a/example/scalalib/basic/1-simple/build.mill b/example/scalalib/basic/1-simple/build.mill index 0274cd20ec1..057b73ff159 100644 --- a/example/scalalib/basic/1-simple/build.mill +++ b/example/scalalib/basic/1-simple/build.mill @@ -25,7 +25,7 @@ object foo extends ScalaModule { // of the example (including supporting files) via the *browse* link. The only requirement is // that you have some version of the JVM installed; the `./mill` script takes // care of any further dependencies that need to be downloaded. All examples -// in this documentation site are executable and are continually exercised as +// in this documentation site are executable and are continually exercised as // part of Mill's CI workflows, and they range from the simple hello-world // projects on this page to more sophisticated // xref:{language-small}lib/web-examples.adoc[web build examples] or @@ -161,4 +161,4 @@ error: Missing argument: --text