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 is

Hello!

Groovy!

+ 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 is

Hello!

Groovy!

./mill foo.run @@ -71,7 +70,6 @@ Contents of groovy-generated.html is

Hello!

Foo Groovy!

Hello!

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 // Mill build files are xref:depth/why-scala.adoc[written in Scala], but you do not need // to have prior experience in Scala to read or write them. Like Gradle Groovy or Maven // XML, anyone can learn enough Scala for Mill without needing to become an expert in -// the language. \ No newline at end of file +// the language. diff --git a/example/scalalib/basic/2-custom-build-logic/build.mill b/example/scalalib/basic/2-custom-build-logic/build.mill index 25043a28e96..8d468940f7f 100644 --- a/example/scalalib/basic/2-custom-build-logic/build.mill +++ b/example/scalalib/basic/2-custom-build-logic/build.mill @@ -43,7 +43,6 @@ object foo extends ScalaModule { // } // ``` - /** Usage > mill foo.run @@ -85,4 +84,3 @@ Inputs: // quickly, they ensure that custom build logic remains performant and // maintainable even as the complexity of your project grows. // - diff --git a/example/scalalib/basic/3-multi-module/build.mill b/example/scalalib/basic/3-multi-module/build.mill index ef0f3501c89..ff71d38eb55 100644 --- a/example/scalalib/basic/3-multi-module/build.mill +++ b/example/scalalib/basic/3-multi-module/build.mill @@ -128,4 +128,3 @@ Bar.value:

world

// For more details on the query syntax, check out the // xref:fundamentals/query-syntax.adoc[query syntax documentation] - diff --git a/example/scalalib/basic/3-multi-module/foo/src/Foo.scala b/example/scalalib/basic/3-multi-module/foo/src/Foo.scala index 952d4d41dbc..6b3f89a904a 100644 --- a/example/scalalib/basic/3-multi-module/foo/src/Foo.scala +++ b/example/scalalib/basic/3-multi-module/foo/src/Foo.scala @@ -2,8 +2,10 @@ package foo import mainargs.{main, ParserForMethods, arg} object Foo { @main - def main(@arg(name = "foo-text") fooText: String, - @arg(name = "bar-text") barText: String): Unit = { + def main( + @arg(name = "foo-text") fooText: String, + @arg(name = "bar-text") barText: String + ): Unit = { println("Foo.value: " + fooText) println("Bar.value: " + bar.Bar.generateHtml(barText)) } diff --git a/example/scalalib/basic/4-compat-modules/build.mill b/example/scalalib/basic/4-compat-modules/build.mill index dc9d30c7294..a328f279ec4 100644 --- a/example/scalalib/basic/4-compat-modules/build.mill +++ b/example/scalalib/basic/4-compat-modules/build.mill @@ -16,7 +16,6 @@ object foo extends SbtModule { } } - object bar extends Cross[BarModule]("2.12.17", "2.13.8") trait BarModule extends CrossSbtModule { object test extends CrossSbtTests { @@ -25,7 +24,6 @@ trait BarModule extends CrossSbtModule { } } - // `SbtModule`/`CrossSbtModule` are variants of `ScalaModule`/`CrossScalaModule` // that use the more verbose folder layout of SBT, Maven, and other tools: // @@ -65,4 +63,4 @@ Bar.value: Hello World Scala library version 2.13.8... > mill bar[2.12.17].run Bar.value: Hello World Scala library version 2.12.17... -*/ \ No newline at end of file +*/ diff --git a/example/scalalib/basic/5-builtin-commands/build.mill b/example/scalalib/basic/5-builtin-commands/build.mill index 0457e6e5cbc..7fec49425c3 100644 --- a/example/scalalib/basic/5-builtin-commands/build.mill +++ b/example/scalalib/basic/5-builtin-commands/build.mill @@ -69,7 +69,6 @@ foo.artifactName // and `+__+` as a placeholder for many segments. // Lists within curly braces (`{`, `}`) are also supported. - /** Usage > mill resolve foo.{compile,run} @@ -152,7 +151,6 @@ Inputs: } */ - // `show` is also useful for interacting with Mill from external tools, since the // JSON it outputs is structured and easily parsed and manipulated. You can easily // pipe the `show` output into a python script or `jq` to manipulate it further. @@ -207,7 +205,6 @@ Inputs: // one-or-more tasks via Mill wildcard queries, since the `{"": }` // structure remains the same regardless of how many values the query returns. - // == path // `mill path` prints out a dependency chain between the first task and the @@ -287,7 +284,6 @@ foo.compileClasspath */ - // == visualize // /** Usage @@ -409,4 +405,3 @@ kotlinlib/web/1-hello-ktor // project isn't going to be everything that you need, at least it'll get most of the // tedious boilerplate set up, so you can hit the group running working on the things // that are unique to your particular project. - diff --git a/example/scalalib/basic/5-builtin-commands/foo/src/Foo.scala b/example/scalalib/basic/5-builtin-commands/foo/src/Foo.scala index bc1ef1e8b66..799f75557d8 100644 --- a/example/scalalib/basic/5-builtin-commands/foo/src/Foo.scala +++ b/example/scalalib/basic/5-builtin-commands/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-text") barText: String): Unit = { + def main( + @arg(name = "foo-text") fooText: String, + @arg(name = "bar-text") barText: String + ): Unit = { println("Foo.value: " + Foo.value) bar.Bar.printText(barText) } diff --git a/example/scalalib/basic/6-realistic/build.mill b/example/scalalib/basic/6-realistic/build.mill index bda540a5cc5..df445056bc6 100644 --- a/example/scalalib/basic/6-realistic/build.mill +++ b/example/scalalib/basic/6-realistic/build.mill @@ -134,4 +134,4 @@ Foo.value:

hello

Bar.value:

world Specific code for Scala 2.x

Qux.value: 31337 -*/ \ No newline at end of file +*/ diff --git a/example/scalalib/dependencies/2-run-compile-deps/build.mill b/example/scalalib/dependencies/2-run-compile-deps/build.mill index e83d3b7a054..4f6c4ea0157 100644 --- a/example/scalalib/dependencies/2-run-compile-deps/build.mill +++ b/example/scalalib/dependencies/2-run-compile-deps/build.mill @@ -50,7 +50,6 @@ object bar extends ScalaModule { */ - // NOTE: Compile-time dependencies are translated to `provided`-scoped // dependencies when publish to Maven or Ivy-Repositories. // @@ -71,5 +70,3 @@ object bar extends ScalaModule { // // TIP: Scala Steward can also keep your // xref:cli/installation-ide#_automatic_mill_updates[Mill version up-to-date]. - - diff --git a/example/scalalib/dependencies/3-unmanaged-jars/build.mill b/example/scalalib/dependencies/3-unmanaged-jars/build.mill index 5ca717046f5..72ef010012a 100644 --- a/example/scalalib/dependencies/3-unmanaged-jars/build.mill +++ b/example/scalalib/dependencies/3-unmanaged-jars/build.mill @@ -31,4 +31,3 @@ Key: name, Value: John Key: age, Value: 30 */ - diff --git a/example/scalalib/dependencies/5-repository-config/build.mill b/example/scalalib/dependencies/5-repository-config/build.mill index 771213e249e..e749f659e32 100644 --- a/example/scalalib/dependencies/5-repository-config/build.mill +++ b/example/scalalib/dependencies/5-repository-config/build.mill @@ -47,7 +47,6 @@ object foo extends ScalaModule { // // You can also set the environment variable `COURSIER_MIRRORS` or the jvm property `coursier.mirrors` to specify config file location. - // To add custom resolvers to the initial bootstrap of the build, you can create a // custom `ZincWorkerModule` (named after the https://github.com/sbt/zinc[Zinc Incremental compiler] // used to compile the `build.mill` files) and override the `zincWorker` method in your @@ -64,7 +63,7 @@ object bar extends ScalaModule { def zincWorker = ModuleRef(CustomZincWorkerModule) // ... rest of your build definitions - def repositoriesTask = Task.Anon {super.repositoriesTask() ++ sonatypeReleases} + def repositoriesTask = Task.Anon { super.repositoriesTask() ++ sonatypeReleases } } //// SNIPPET:END diff --git a/example/scalalib/linting/1-scalafmt/build.mill b/example/scalalib/linting/1-scalafmt/build.mill index db30377ace1..910243dc0b7 100644 --- a/example/scalalib/linting/1-scalafmt/build.mill +++ b/example/scalalib/linting/1-scalafmt/build.mill @@ -62,4 +62,4 @@ object Foo { // If entering the long fully-qualified module name `mill.scalalib.scalafmt.ScalafmtModule/` // is tedious, you can add // an xref:fundamentals/modules.adoc#_aliasing_external_modules[External Module Alias] -// to give it a shorter name that's easier to type \ No newline at end of file +// to give it a shorter name that's easier to type diff --git a/example/scalalib/linting/2-contrib-scoverage/build.mill b/example/scalalib/linting/2-contrib-scoverage/build.mill index d4c3b37626b..6f3a51bbaf7 100644 --- a/example/scalalib/linting/2-contrib-scoverage/build.mill +++ b/example/scalalib/linting/2-contrib-scoverage/build.mill @@ -12,7 +12,7 @@ object `package` extends RootModule with ScoverageModule { ivy"com.lihaoyi::mainargs:0.6.2" ) - object test extends ScoverageTests /*with TestModule.Utest */{ + object test extends ScoverageTests /*with TestModule.Utest */ { def ivyDeps = Agg(ivy"com.lihaoyi::utest:0.8.4") def testFramework = "utest.runner.Framework" } diff --git a/example/scalalib/linting/3-acyclic/build.mill b/example/scalalib/linting/3-acyclic/build.mill index 7e3a8c351d5..c766eb8ea4d 100644 --- a/example/scalalib/linting/3-acyclic/build.mill +++ b/example/scalalib/linting/3-acyclic/build.mill @@ -50,7 +50,6 @@ symbol: object Bar // is only one way. For this example, we remove the reference to `Foo` in `Bar.scala`, // which allows the code to compile: - /** Usage > sed -i.bak 's/Foo/Bar/g' src/Bar.scala diff --git a/example/scalalib/linting/3-acyclic/src/Bar.scala b/example/scalalib/linting/3-acyclic/src/Bar.scala index bf34b54b8f4..2fae3bec2d0 100644 --- a/example/scalalib/linting/3-acyclic/src/Bar.scala +++ b/example/scalalib/linting/3-acyclic/src/Bar.scala @@ -1,4 +1,4 @@ package foo -object Bar{ +object Bar { val value = Foo + " world" } diff --git a/example/scalalib/linting/3-acyclic/src/Foo.scala b/example/scalalib/linting/3-acyclic/src/Foo.scala index 5adfa327c4c..e3f89cb64eb 100644 --- a/example/scalalib/linting/3-acyclic/src/Foo.scala +++ b/example/scalalib/linting/3-acyclic/src/Foo.scala @@ -1,7 +1,7 @@ package foo -object Foo{ +object Foo { val value = 123 - def main(args: Array[String]): Unit= { + def main(args: Array[String]): Unit = { println("hello " + Bar) } } diff --git a/example/scalalib/module/1-common-config/build.mill b/example/scalalib/module/1-common-config/build.mill index f617b2c9b59..bb142c0abe5 100644 --- a/example/scalalib/module/1-common-config/build.mill +++ b/example/scalalib/module/1-common-config/build.mill @@ -15,25 +15,25 @@ object `package` extends RootModule with ScalaModule { // You can have arbitrary numbers of third-party dependencies def ivyDeps = Agg( ivy"com.lihaoyi::scalatags:0.8.2", - ivy"com.lihaoyi::os-lib:0.10.7", + ivy"com.lihaoyi::os-lib:0.10.7" ) // Choose a main class to use for `.run` if there are multiple present def mainClass: T[Option[String]] = Some("foo.Foo2") // Add (or replace) source folders for the module to use - def sources = Task.Sources{ + def sources = Task.Sources { super.sources() ++ Seq(PathRef(millSourcePath / "custom-src")) } // Add (or replace) resource folders for the module to use - def resources = Task.Sources{ + def resources = Task.Sources { super.resources() ++ Seq(PathRef(millSourcePath / "custom-resources")) } // Generate sources at build time def generatedSources: T[Seq[PathRef]] = Task { - for(name <- Seq("A", "B", "C")) os.write( + for (name <- Seq("A", "B", "C")) os.write( Task.dest / s"Foo$name.scala", s""" |package foo diff --git a/example/scalalib/module/1-common-config/custom-src/Foo2.scala b/example/scalalib/module/1-common-config/custom-src/Foo2.scala index 622b2c9fe1f..67b70c4314b 100644 --- a/example/scalalib/module/1-common-config/custom-src/Foo2.scala +++ b/example/scalalib/module/1-common-config/custom-src/Foo2.scala @@ -18,4 +18,3 @@ object Foo2 { if (sys.env.contains("MY_CUSTOM_ENV")) println("MY_CUSTOM_ENV: " + sys.env("MY_CUSTOM_ENV")) } } - diff --git a/example/scalalib/module/11-main-class/build.mill b/example/scalalib/module/11-main-class/build.mill index 87fe0f688c0..33a7d1eea1e 100644 --- a/example/scalalib/module/11-main-class/build.mill +++ b/example/scalalib/module/11-main-class/build.mill @@ -19,4 +19,4 @@ object `package` extends RootModule with ScalaModule { > ./mill run Hello Qux -*/ \ No newline at end of file +*/ diff --git a/example/scalalib/module/13-assembly-config/build.mill b/example/scalalib/module/13-assembly-config/build.mill index 805f91890bb..df8aeda18e5 100644 --- a/example/scalalib/module/13-assembly-config/build.mill +++ b/example/scalalib/module/13-assembly-config/build.mill @@ -46,4 +46,4 @@ Loaded application.conf from resources:... ...Foo Application Conf ...Bar Application Conf -*/ \ No newline at end of file +*/ diff --git a/example/scalalib/module/14-cross-scala-version/build.mill b/example/scalalib/module/14-cross-scala-version/build.mill index 440f3babb9a..bc96e413db6 100644 --- a/example/scalalib/module/14-cross-scala-version/build.mill +++ b/example/scalalib/module/14-cross-scala-version/build.mill @@ -4,7 +4,7 @@ import mill._, scalalib._ val scalaVersions = Seq("2.12.17", "2.13.8") object foo extends Cross[FooModule](scalaVersions) -trait FooModule extends CrossScalaModule{ +trait FooModule extends CrossScalaModule { def moduleDeps = Seq(bar()) } @@ -52,9 +52,8 @@ Bar.value: bar-value // cross-module to depend on. You can also pass the `crossScalaVersion` // explicitly to select the right version of the cross-module: - object foo2 extends Cross[Foo2Module](scalaVersions) -trait Foo2Module extends CrossScalaModule{ +trait Foo2Module extends CrossScalaModule { def moduleDeps = Seq(bar(crossScalaVersion)) } diff --git a/example/scalalib/module/15-unidoc/build.mill b/example/scalalib/module/15-unidoc/build.mill index 96c4abdb07a..21b70e10636 100644 --- a/example/scalalib/module/15-unidoc/build.mill +++ b/example/scalalib/module/15-unidoc/build.mill @@ -1,11 +1,11 @@ package build import mill._, scalalib._ -object foo extends ScalaModule with UnidocModule{ +object foo extends ScalaModule with UnidocModule { def scalaVersion = "2.13.8" def moduleDeps = Seq(bar, qux) - object bar extends ScalaModule{ + object bar extends ScalaModule { def scalaVersion = "2.13.8" } @@ -49,4 +49,4 @@ object foo extends ScalaModule with UnidocModule{ > ./mill show foo.unidocSite -*/ \ No newline at end of file +*/ diff --git a/example/scalalib/module/2-custom-tasks/build.mill b/example/scalalib/module/2-custom-tasks/build.mill index 4acb40add96..6ce46d53db8 100644 --- a/example/scalalib/module/2-custom-tasks/build.mill +++ b/example/scalalib/module/2-custom-tasks/build.mill @@ -17,7 +17,7 @@ object `package` extends RootModule with ScalaModule { def ivyDeps = Agg(ivy"com.lihaoyi::mainargs:0.4.0") def generatedSources: T[Seq[PathRef]] = Task { - val prettyIvyDeps = for(ivyDep <- ivyDeps()) yield { + val prettyIvyDeps = for (ivyDep <- ivyDeps()) yield { val org = ivyDep.dep.module.organization.value val name = ivyDep.dep.module.name.value val version = ivyDep.dep.version @@ -134,4 +134,4 @@ my.line.count: 14 // particular task all live in one place, avoiding file-name conflicts, // preventing race conditions when tasks evaluate in parallel, and // letting Mill automatically invalidate the files when the task's inputs -// change. \ No newline at end of file +// change. diff --git a/example/scalalib/module/3-override-tasks/build.mill b/example/scalalib/module/3-override-tasks/build.mill index c8724dc25d4..87a539413c8 100644 --- a/example/scalalib/module/3-override-tasks/build.mill +++ b/example/scalalib/module/3-override-tasks/build.mill @@ -74,4 +74,4 @@ Compiling... Running... Hello World -*/ \ No newline at end of file +*/ diff --git a/example/scalalib/module/4-compilation-execution-flags/build.mill b/example/scalalib/module/4-compilation-execution-flags/build.mill index f7ecc02df35..eaee80abacb 100644 --- a/example/scalalib/module/4-compilation-execution-flags/build.mill +++ b/example/scalalib/module/4-compilation-execution-flags/build.mill @@ -2,7 +2,7 @@ package build import mill._, scalalib._ -object `package` extends RootModule with ScalaModule{ +object `package` extends RootModule with ScalaModule { def scalaVersion = "2.13.8" def scalacOptions = Seq("-Ydelambdafy:inline") def forkArgs = Seq("-Xmx4g", "-Dmy.jvm.property=hello") @@ -11,7 +11,6 @@ object `package` extends RootModule with ScalaModule{ // You can pass flags to the Scala compiler via `scalacOptions`. - /** Usage > ./mill run diff --git a/example/scalalib/module/7-resources/build.mill b/example/scalalib/module/7-resources/build.mill index b04a825ff23..ace003c8d92 100644 --- a/example/scalalib/module/7-resources/build.mill +++ b/example/scalalib/module/7-resources/build.mill @@ -53,7 +53,6 @@ object foo extends ScalaModule { // // Example application code demonstrating the techniques above can be seen below: - /** See Also: foo/resources/file.txt */ /** See Also: foo/test/resources/test-file-a.txt */ /** See Also: foo/test/resources/test-file-b.txt */ @@ -66,7 +65,6 @@ object foo extends ScalaModule { //// SNIPPET:END - // // // Note that tests require that you pass in any files that they depend on explicitly. @@ -81,7 +79,3 @@ object foo extends ScalaModule { // If you have legacy tests that need to run in the project root folder to work, you // can configure your test suite with `def testSandboxWorkingDir = false` to disable // the sandbox and make the tests run in the project root. - - - - diff --git a/example/scalalib/module/7-resources/foo/test/src/FooTests.scala b/example/scalalib/module/7-resources/foo/test/src/FooTests.scala index ab39b603263..a4f8e59e358 100644 --- a/example/scalalib/module/7-resources/foo/test/src/FooTests.scala +++ b/example/scalalib/module/7-resources/foo/test/src/FooTests.scala @@ -19,7 +19,7 @@ object FooTests extends TestSuite { // Use `MILL_TEST_RESOURCE_DIR` to list files available in resource folder assert( os.list(testFileResourceDir).sorted == - Seq(testFileResourceDir / "test-file-a.txt", testFileResourceDir / "test-file-b.txt") + Seq(testFileResourceDir / "test-file-a.txt", testFileResourceDir / "test-file-b.txt") ) // Use the `OTHER_FILES_DIR` configured in your build to access the diff --git a/example/scalalib/module/9-docjar/bar/src/Bar.scala b/example/scalalib/module/9-docjar/bar/src/Bar.scala index 4cbcfb9ea99..5c8666afd0e 100644 --- a/example/scalalib/module/9-docjar/bar/src/Bar.scala +++ b/example/scalalib/module/9-docjar/bar/src/Bar.scala @@ -1,4 +1,5 @@ package bar + /** * My Awesome Docs for class Bar */ diff --git a/example/scalalib/module/9-docjar/build.mill b/example/scalalib/module/9-docjar/build.mill index 8e71b18e362..31017223633 100644 --- a/example/scalalib/module/9-docjar/build.mill +++ b/example/scalalib/module/9-docjar/build.mill @@ -12,7 +12,6 @@ object foo extends ScalaModule { def scalaDocOptions = Seq("-siteroot", "mydocs", "-no-link-warnings") } - /** Usage > ./mill show foo.docJar @@ -69,7 +68,6 @@ object bar extends ScalaModule { // have a full static site including your API docs, your blog, and your // documentation. - /** Usage > ./mill show bar.docJar @@ -78,4 +76,4 @@ object bar extends ScalaModule { ... ...

My Awesome Docs for class Bar

... -*/ \ No newline at end of file +*/ diff --git a/example/scalalib/native/1-simple/build.mill b/example/scalalib/native/1-simple/build.mill index 50cdf487a81..67f1dcc2088 100644 --- a/example/scalalib/native/1-simple/build.mill +++ b/example/scalalib/native/1-simple/build.mill @@ -10,7 +10,7 @@ object `package` extends RootModule with ScalaNativeModule { ivy"com.lihaoyi::mainargs::0.7.6" ) - object test extends ScalaNativeTests with TestModule.Utest{ + object test extends ScalaNativeTests with TestModule.Utest { def ivyDeps = Agg(ivy"com.lihaoyi::utest::0.8.4") def testFramework = "utest.runner.Framework" } diff --git a/example/scalalib/native/1-simple/src/Foo.scala b/example/scalalib/native/1-simple/src/Foo.scala index 8b60d9a3747..1bb9145f0ee 100644 --- a/example/scalalib/native/1-simple/src/Foo.scala +++ b/example/scalalib/native/1-simple/src/Foo.scala @@ -5,13 +5,13 @@ import scala.scalanative.unsafe._ import mainargs.{main, ParserForMethods} object Foo { - - def generateHtml(text: String) (using Zone) = { + + def generateHtml(text: String)(using Zone) = { val html = "

" + text + "

\n" val cResult = toCString(html) cResult - + } @main @@ -21,4 +21,3 @@ object Foo { def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args) } - diff --git a/example/scalalib/native/1-simple/test/src/FooTests.scala b/example/scalalib/native/1-simple/test/src/FooTests.scala index 33ce63fc225..27f3cd7cf75 100644 --- a/example/scalalib/native/1-simple/test/src/FooTests.scala +++ b/example/scalalib/native/1-simple/test/src/FooTests.scala @@ -17,4 +17,3 @@ object FooTests extends TestSuite { } } } - diff --git a/example/scalalib/native/2-interop/build.mill b/example/scalalib/native/2-interop/build.mill index 7852a3874f1..e40e8a924d2 100644 --- a/example/scalalib/native/2-interop/build.mill +++ b/example/scalalib/native/2-interop/build.mill @@ -12,7 +12,6 @@ object `package` extends RootModule with ScalaNativeModule { } - // This is an example of how to use Mill to compile C code together with your Scala Native // code. // @@ -53,4 +52,3 @@ Reversed: !dlroW ,olleH Tests: 1, Passed: 1, Failed: 0 */ - diff --git a/example/scalalib/native/2-interop/src/foo/HelloWorld.scala b/example/scalalib/native/2-interop/src/foo/HelloWorld.scala index fad308ae8e0..e8479f3a735 100644 --- a/example/scalalib/native/2-interop/src/foo/HelloWorld.scala +++ b/example/scalalib/native/2-interop/src/foo/HelloWorld.scala @@ -19,4 +19,3 @@ object Main { object HelloWorld { def reverseString(str: CString): CString = extern } - diff --git a/example/scalalib/native/2-interop/test/src/HelloWorldTests.scala b/example/scalalib/native/2-interop/test/src/HelloWorldTests.scala index 5bdc17ff9cb..3b80ea6638b 100644 --- a/example/scalalib/native/2-interop/test/src/HelloWorldTests.scala +++ b/example/scalalib/native/2-interop/test/src/HelloWorldTests.scala @@ -17,4 +17,3 @@ object HelloWorldTest extends TestSuite { } } } - diff --git a/example/scalalib/native/3-multi-module/bar/src/Bar.scala b/example/scalalib/native/3-multi-module/bar/src/Bar.scala index a86500e47b7..d900039c10f 100644 --- a/example/scalalib/native/3-multi-module/bar/src/Bar.scala +++ b/example/scalalib/native/3-multi-module/bar/src/Bar.scala @@ -20,5 +20,3 @@ object HelloWorldBar { // Name and signature of C function def stringLength(str: CString): CInt = extern } - - diff --git a/example/scalalib/native/3-multi-module/bar/test/src/BarTests.scala b/example/scalalib/native/3-multi-module/bar/test/src/BarTests.scala index cb5585b99e2..fc1be16d8df 100644 --- a/example/scalalib/native/3-multi-module/bar/test/src/BarTests.scala +++ b/example/scalalib/native/3-multi-module/bar/test/src/BarTests.scala @@ -12,4 +12,3 @@ object BarTests extends TestSuite { } } } - diff --git a/example/scalalib/native/3-multi-module/foo/src/Foo.scala b/example/scalalib/native/3-multi-module/foo/src/Foo.scala index 39dad3570b8..6ff1da3731a 100644 --- a/example/scalalib/native/3-multi-module/foo/src/Foo.scala +++ b/example/scalalib/native/3-multi-module/foo/src/Foo.scala @@ -6,15 +6,23 @@ import mainargs.{main, ParserForMethods, arg} object Foo { @main - def main(@arg(name = "foo-text") fooText: String, - @arg(name = "bar-text") barText: String): Unit = Zone { - - val cFooText = toCString(fooText) - val cBarText = toCString(barText) - - stdio.printf(c"Foo.value: The vowel density of '%s' is %d\n", cFooText, HelloWorldFoo.vowelDensity(cFooText)) - stdio.printf(c"Bar.value: The string length of '%s' is %d\n", cBarText, bar.HelloWorldBar.stringLength(cBarText)) - } + def main(@arg(name = "foo-text") fooText: String, @arg(name = "bar-text") barText: String): Unit = + Zone { + + val cFooText = toCString(fooText) + val cBarText = toCString(barText) + + stdio.printf( + c"Foo.value: The vowel density of '%s' is %d\n", + cFooText, + HelloWorldFoo.vowelDensity(cFooText) + ) + stdio.printf( + c"Bar.value: The string length of '%s' is %d\n", + cBarText, + bar.HelloWorldBar.stringLength(cBarText) + ) + } def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args) } @@ -25,5 +33,3 @@ object HelloWorldFoo { // Name and signature of C function def vowelDensity(str: CString): CInt = extern } - - diff --git a/example/scalalib/native/4-common-config/build.mill b/example/scalalib/native/4-common-config/build.mill index 2134a1c76d7..510d85ab0f4 100644 --- a/example/scalalib/native/4-common-config/build.mill +++ b/example/scalalib/native/4-common-config/build.mill @@ -47,5 +47,3 @@ true ... */ - - diff --git a/example/scalalib/native/4-common-config/src/Foo.scala b/example/scalalib/native/4-common-config/src/Foo.scala index b77d8d2632d..32415ff110b 100644 --- a/example/scalalib/native/4-common-config/src/Foo.scala +++ b/example/scalalib/native/4-common-config/src/Foo.scala @@ -6,16 +6,15 @@ import fansi._ object Foo { - def generateHtml(text: String) (using Zone) = { + def generateHtml(text: String)(using Zone) = { val colored = Console.RED + "

" + text + "

" + Console.RESET val cResult = toCString(colored) cResult } - + def main(args: Array[String]): Unit = Zone { val value = generateHtml("hello") stdio.printf(c"Value: %s\n", value) } } - diff --git a/example/scalalib/testing/1-test-suite/build.mill b/example/scalalib/testing/1-test-suite/build.mill index ecae6b0984f..69b4a6a84fa 100644 --- a/example/scalalib/testing/1-test-suite/build.mill +++ b/example/scalalib/testing/1-test-suite/build.mill @@ -123,7 +123,6 @@ object bar extends ScalaModule { // `foo.test` in the command line. e.g. {utest-github-url}[uTest] // lets you pass in a selector to decide which test to run, which in Mill would be: - /** Usage > mill bar.test bar.BarTests.hello @@ -131,4 +130,4 @@ object bar extends ScalaModule { */ -// This command only runs the `hello` test case in the `bar.BarTests` test suite class. \ No newline at end of file +// This command only runs the `hello` test case in the `bar.BarTests` test suite class. diff --git a/example/scalalib/testing/2-test-deps/build.mill b/example/scalalib/testing/2-test-deps/build.mill index 217cc30bea0..00ac007f87a 100644 --- a/example/scalalib/testing/2-test-deps/build.mill +++ b/example/scalalib/testing/2-test-deps/build.mill @@ -24,7 +24,6 @@ object qux extends ScalaModule { } } - object baz extends ScalaModule { def scalaVersion = "2.13.8" @@ -58,4 +57,3 @@ Using BazTestUtils.bazAssertEquals ... */ - diff --git a/example/scalalib/testing/3-integration-suite/build.mill b/example/scalalib/testing/3-integration-suite/build.mill index cd56d03c148..203ab571c89 100644 --- a/example/scalalib/testing/3-integration-suite/build.mill +++ b/example/scalalib/testing/3-integration-suite/build.mill @@ -18,11 +18,9 @@ object qux extends ScalaModule { } //// SNIPPET:END - // These two test modules will expect their sources to be in their respective `qux/test` and // `qux/integration` folder respectively - /** Usage > mill 'qux.{test,integration}' # run both test suites @@ -32,4 +30,4 @@ object qux extends ScalaModule { > mill __.integration.testCached # run all integration test suites -*/ \ No newline at end of file +*/ diff --git a/example/scalalib/testing/4-test-grouping/build.mill b/example/scalalib/testing/4-test-grouping/build.mill index 3f216c059b0..a1f73c017f8 100644 --- a/example/scalalib/testing/4-test-grouping/build.mill +++ b/example/scalalib/testing/4-test-grouping/build.mill @@ -15,6 +15,7 @@ object foo extends ScalaModule { def testForkGrouping = discoveredTestClasses().grouped(1).toSeq } } + /** See Also: foo/test/src/HelloTests.scala */ /** See Also: foo/test/src/WorldTests.scala */ @@ -60,4 +61,4 @@ out/foo/test/test.dest/test-report.xml // have to run alone, while other test classes may be better-behaved and OK to run in a group // // In general, `testForkGrouping` leaves it up to you how you want to group your tests for -// execution, based on the unique constraints of your test suite. \ No newline at end of file +// execution, based on the unique constraints of your test suite. diff --git a/example/scalalib/web/1-todo-webapp/build.mill b/example/scalalib/web/1-todo-webapp/build.mill index 0a107030325..b8ff3c15e3a 100644 --- a/example/scalalib/web/1-todo-webapp/build.mill +++ b/example/scalalib/web/1-todo-webapp/build.mill @@ -13,7 +13,7 @@ object `package` extends RootModule with ScalaModule { def ivyDeps = Agg( ivy"com.lihaoyi::utest::0.8.4", - ivy"com.lihaoyi::requests::0.6.9", + ivy"com.lihaoyi::requests::0.6.9" ) } } @@ -35,4 +35,4 @@ object `package` extends RootModule with ScalaModule { > ./mill clean runBackground -*/ \ No newline at end of file +*/ diff --git a/example/scalalib/web/2-webapp-cache-busting/build.mill b/example/scalalib/web/2-webapp-cache-busting/build.mill index 31edc74cc44..c1447e1606e 100644 --- a/example/scalalib/web/2-webapp-cache-busting/build.mill +++ b/example/scalalib/web/2-webapp-cache-busting/build.mill @@ -29,7 +29,7 @@ object `package` extends RootModule with ScalaModule { def testFramework = "utest.runner.Framework" def ivyDeps = Agg( ivy"com.lihaoyi::utest::0.8.4", - ivy"com.lihaoyi::requests::0.6.9", + ivy"com.lihaoyi::requests::0.6.9" ) } @@ -43,7 +43,6 @@ object `package` extends RootModule with ScalaModule { } } - // This example demonstrates how to implement webapp "cache busting" in Mill, // where we serve static files with a hash appended to the filename, and save // a mapping of filename to hashed filename so that the web server can serve diff --git a/example/scalalib/web/3-scalajs-module/build.mill b/example/scalalib/web/3-scalajs-module/build.mill index 7ffd8402a27..15c3e648d25 100644 --- a/example/scalalib/web/3-scalajs-module/build.mill +++ b/example/scalalib/web/3-scalajs-module/build.mill @@ -52,4 +52,4 @@ stringifiedJsObject: ["hello","world","!"] */ // Note that running Scala.js modules locally requires the `node` Javascript -// runtime to be installed on your machine. \ No newline at end of file +// runtime to be installed on your machine. diff --git a/example/scalalib/web/4-webapp-scalajs/build.mill b/example/scalalib/web/4-webapp-scalajs/build.mill index bf027c71ff9..95b5e48d5c5 100644 --- a/example/scalalib/web/4-webapp-scalajs/build.mill +++ b/example/scalalib/web/4-webapp-scalajs/build.mill @@ -24,7 +24,7 @@ object `package` extends RootModule with ScalaModule { def ivyDeps = Agg( ivy"com.lihaoyi::utest::0.8.4", - ivy"com.lihaoyi::requests::0.6.9", + ivy"com.lihaoyi::requests::0.6.9" ) } @@ -63,4 +63,4 @@ object `package` extends RootModule with ScalaModule { > ./mill clean runBackground -*/ \ No newline at end of file +*/ diff --git a/example/scalalib/web/4-webapp-scalajs/client/src/ClientApp.scala b/example/scalalib/web/4-webapp-scalajs/client/src/ClientApp.scala index 77c4b4b6e7f..b522f7195c5 100644 --- a/example/scalalib/web/4-webapp-scalajs/client/src/ClientApp.scala +++ b/example/scalalib/web/4-webapp-scalajs/client/src/ClientApp.scala @@ -1,6 +1,6 @@ package client import org.scalajs.dom -object ClientApp{ +object ClientApp { var state = "all" var todoApp = dom.document.getElementsByClassName("todoapp")(0) @@ -11,7 +11,7 @@ object ClientApp{ method = dom.HttpMethod.POST } ).then[String](response => response.text()) - .then[Unit]{ text => + .then[Unit] { text => todoApp.innerHTML = text initListeners() } @@ -45,11 +45,12 @@ object ClientApp{ bindEvent("todo-completed", s"/list/completed", Some("completed")) bindEvent("clear-completed", s"/clear-completed/$state", None) - val newTodoInput = dom.document.getElementsByClassName("new-todo")(0).asInstanceOf[dom.HTMLInputElement] + val newTodoInput = + dom.document.getElementsByClassName("new-todo")(0).asInstanceOf[dom.HTMLInputElement] newTodoInput.addEventListener( "keydown", (evt: dom.KeyboardEvent) => { - if (evt.keyCode == 13){ + if (evt.keyCode == 13) { dom.fetch( s"/add/$state", new dom.RequestInit { @@ -57,7 +58,7 @@ object ClientApp{ body = newTodoInput.value } ).then[String](response => response.text()) - .then[Unit]{text => + .then[Unit] { text => newTodoInput.value = "" todoApp.innerHTML = text initListeners() diff --git a/example/scalalib/web/5-webapp-scalajs-shared/build.mill b/example/scalalib/web/5-webapp-scalajs-shared/build.mill index 495c0f65c75..c4929e6ad21 100644 --- a/example/scalalib/web/5-webapp-scalajs-shared/build.mill +++ b/example/scalalib/web/5-webapp-scalajs-shared/build.mill @@ -25,7 +25,7 @@ object `package` extends RootModule with AppScalaModule { def ivyDeps = Agg( ivy"com.lihaoyi::utest::0.8.4", - ivy"com.lihaoyi::requests::0.6.9", + ivy"com.lihaoyi::requests::0.6.9" ) } @@ -33,7 +33,7 @@ object `package` extends RootModule with AppScalaModule { trait SharedModule extends AppScalaModule with PlatformScalaModule { def ivyDeps = Agg( ivy"com.lihaoyi::scalatags::0.12.0", - ivy"com.lihaoyi::upickle::3.0.0", + ivy"com.lihaoyi::upickle::3.0.0" ) } @@ -81,4 +81,4 @@ object `package` extends RootModule with AppScalaModule { > ./mill clean runBackground -*/ \ No newline at end of file +*/ diff --git a/example/scalalib/web/5-webapp-scalajs-shared/client/src/ClientApp.scala b/example/scalalib/web/5-webapp-scalajs-shared/client/src/ClientApp.scala index 53be9ddc64f..20e268655d8 100644 --- a/example/scalalib/web/5-webapp-scalajs-shared/client/src/ClientApp.scala +++ b/example/scalalib/web/5-webapp-scalajs-shared/client/src/ClientApp.scala @@ -1,7 +1,7 @@ package client import org.scalajs.dom import shared.{Todo, Shared} -object ClientApp{ +object ClientApp { var state = "all" var todoApp = dom.document.getElementsByClassName("todoapp")(0) @@ -12,7 +12,7 @@ object ClientApp{ method = dom.HttpMethod.POST } ).`then`[String](response => response.text()) - .`then`[Unit]{ text => + .`then`[Unit] { text => todoApp.innerHTML = Shared .renderBody(upickle.default.read[Seq[Todo]](text), state) .render @@ -49,11 +49,12 @@ object ClientApp{ bindEvent("todo-completed", s"/list/completed", Some("completed")) bindEvent("clear-completed", s"/clear-completed/$state", None) - val newTodoInput = dom.document.getElementsByClassName("new-todo")(0).asInstanceOf[dom.HTMLInputElement] + val newTodoInput = + dom.document.getElementsByClassName("new-todo")(0).asInstanceOf[dom.HTMLInputElement] newTodoInput.addEventListener( "keydown", (evt: dom.KeyboardEvent) => { - if (evt.keyCode == 13){ + if (evt.keyCode == 13) { dom.fetch( s"/add/$state", new dom.RequestInit { @@ -61,7 +62,7 @@ object ClientApp{ body = newTodoInput.value } ).`then`[String](response => response.text()) - .`then`[Unit]{text => + .`then`[Unit] { text => newTodoInput.value = "" todoApp.innerHTML = Shared @@ -75,6 +76,5 @@ object ClientApp{ ) } - def main(args: Array[String]): Unit = initListeners() } diff --git a/example/scalalib/web/5-webapp-scalajs-shared/shared/src/Shared.scala b/example/scalalib/web/5-webapp-scalajs-shared/shared/src/Shared.scala index 062d32979eb..6597725430f 100644 --- a/example/scalalib/web/5-webapp-scalajs-shared/shared/src/Shared.scala +++ b/example/scalalib/web/5-webapp-scalajs-shared/shared/src/Shared.scala @@ -8,7 +8,7 @@ object Todo { implicit def todoRW: upickle.default.ReadWriter[Todo] = upickle.default.macroRW[Todo] } -object Shared{ +object Shared { def renderBody(todos: Seq[Todo], state: String) = { val filteredTodos = state match { case "all" => todos.zipWithIndex diff --git a/example/scalalib/web/6-cross-version-platform-publishing/build.mill b/example/scalalib/web/6-cross-version-platform-publishing/build.mill index 16194156646..b018ab34a86 100644 --- a/example/scalalib/web/6-cross-version-platform-publishing/build.mill +++ b/example/scalalib/web/6-cross-version-platform-publishing/build.mill @@ -3,7 +3,8 @@ import mill._, scalalib._, scalajslib._, publish._ object foo extends Cross[FooModule]("2.13.14", "3.3.3") trait FooModule extends Cross.Module[String] { - trait Shared extends CrossScalaModule with CrossValue with PlatformScalaModule with PublishModule { + trait Shared extends CrossScalaModule with CrossValue with PlatformScalaModule + with PublishModule { def publishVersion = "0.0.1" def pomSettings = PomSettings( @@ -28,7 +29,7 @@ trait FooModule extends Cross.Module[String] { } object bar extends Module { - object jvm extends Shared{ + object jvm extends Shared { object test extends ScalaTests with FooTestModule } object js extends SharedJS { diff --git a/example/scalalib/web/8-wasm/build.mill b/example/scalalib/web/8-wasm/build.mill index 1eaa52edfa8..66f2d388a79 100644 --- a/example/scalalib/web/8-wasm/build.mill +++ b/example/scalalib/web/8-wasm/build.mill @@ -2,7 +2,6 @@ package build import mill._, scalalib._, scalajslib._ import mill.scalajslib.api._ - object wasm extends ScalaJSModule { override def scalaVersion = "2.13.14" @@ -38,5 +37,3 @@ hello wasm! // Here we see that scala JS emits a single WASM module, as well as a loader and main.js file. // `main.js` is the entry point of the program, and calls into the wasm module. - - diff --git a/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala b/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala index 7c92a4486d4..e0904fd427f 100644 --- a/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala +++ b/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala @@ -395,11 +395,12 @@ object MultiLevelBuildTests extends UtestIntegrationTestSuite { test("runtimeErrorEdits") - integrationTest { tester => import tester._ - val runErrorSnippet = """{ - |override def runClasspath = Task { - | throw new Exception("boom") - | super.runClasspath() - |}""".stripMargin + val runErrorSnippet = + """{ + |override def runClasspath = Task { + | throw new Exception("boom") + | super.runClasspath() + |}""".stripMargin def causeRuntimeError(p: os.Path) = modifyFile(p, _.replaceFirst("\\{", runErrorSnippet)) diff --git a/kotlinlib/test/src/mill/kotlinlib/js/KotlinJsKotestModuleTests.scala b/kotlinlib/test/src/mill/kotlinlib/js/KotlinJsKotestModuleTests.scala index bfc89a068ee..8abb9e7a2ad 100644 --- a/kotlinlib/test/src/mill/kotlinlib/js/KotlinJsKotestModuleTests.scala +++ b/kotlinlib/test/src/mill/kotlinlib/js/KotlinJsKotestModuleTests.scala @@ -61,7 +61,9 @@ object KotlinJsKotestModuleTests extends TestSuite { |""".stripMargin, testResults.length == 2, testResults.count(result => - result.status == Status.Failure.name() && result.exceptionTrace.getOrElse(Seq.empty).isEmpty + result.status == Status.Failure.name() && result.exceptionTrace.getOrElse( + Seq.empty + ).isEmpty ) == 0 ) } diff --git a/kotlinlib/test/src/mill/kotlinlib/js/KotlinJsKotlinTestPackageModuleTests.scala b/kotlinlib/test/src/mill/kotlinlib/js/KotlinJsKotlinTestPackageModuleTests.scala index f28767c83eb..6972fedd2da 100644 --- a/kotlinlib/test/src/mill/kotlinlib/js/KotlinJsKotlinTestPackageModuleTests.scala +++ b/kotlinlib/test/src/mill/kotlinlib/js/KotlinJsKotlinTestPackageModuleTests.scala @@ -62,7 +62,9 @@ object KotlinJsKotlinTestPackageModuleTests extends TestSuite { |""".stripMargin, testResults.length == 2, testResults.count(result => - result.status == Status.Failure.name() && result.exceptionTrace.getOrElse(Seq.empty).isEmpty + result.status == Status.Failure.name() && result.exceptionTrace.getOrElse( + Seq.empty + ).isEmpty ) == 0 ) } diff --git a/main/define/src/mill/define/Cross.scala b/main/define/src/mill/define/Cross.scala index 101a5d7a3c7..851e34d3f25 100644 --- a/main/define/src/mill/define/Cross.scala +++ b/main/define/src/mill/define/Cross.scala @@ -198,7 +198,8 @@ object Cross { // logic needs to use java reflection to identify sub-modules and java // reflect can only properly identify nested `object`s inside Scala // `object` and `class`es. - val tree = q""" + val tree = + q""" new mill.define.Cross.Factory[$tpe]( makeList = $wrappedT.map{($v1: ${tq""}) => class $concreteCls()(implicit ctx: mill.define.Ctx) extends $tpe{..$newTrees} diff --git a/main/server/src/mill/main/server/Server.scala b/main/server/src/mill/main/server/Server.scala index 096c305ad5f..e59a578cd93 100644 --- a/main/server/src/mill/main/server/Server.scala +++ b/main/server/src/mill/main/server/Server.scala @@ -126,7 +126,9 @@ abstract class Server[T]( val thread = new Thread( () => { try Thread.sleep(acceptTimeoutMillis) - catch { case t: InterruptedException => /* Do Nothing */ } + catch { + case t: InterruptedException => /* Do Nothing */ + } if (interrupt) { interrupted = true serverLog(s"Interrupting after ${acceptTimeoutMillis}ms") diff --git a/main/util/src/mill/util/PromptLogger.scala b/main/util/src/mill/util/PromptLogger.scala index 69714b9b097..f94c407313f 100644 --- a/main/util/src/mill/util/PromptLogger.scala +++ b/main/util/src/mill/util/PromptLogger.scala @@ -76,7 +76,9 @@ private[mill] class PromptLogger( else nonInteractivePromptUpdateIntervalMillis try Thread.sleep(promptUpdateInterval) - catch { case e: InterruptedException => /*do nothing*/ } + catch { + case e: InterruptedException => /*do nothing*/ + } readTerminalDims(terminfoPath).foreach(termDimensions = _) diff --git a/main/util/test/src/mill/util/PipeStreamsTests.scala b/main/util/test/src/mill/util/PipeStreamsTests.scala index ab009adcc1e..d3f818b7cee 100644 --- a/main/util/test/src/mill/util/PipeStreamsTests.scala +++ b/main/util/test/src/mill/util/PipeStreamsTests.scala @@ -79,7 +79,9 @@ object PipeStreamsTests extends TestSuite { sortedGroups ==> expectedLists } - test("multiThreadWriteConcurrentRead") { // multiple writes across different threads interleaved by reads + test( + "multiThreadWriteConcurrentRead" + ) { // multiple writes across different threads interleaved by reads val chunkSize = 20 val chunkCount = 100 val pipe = new PipeStreams(bufferSize = 113) diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index afd41f14f95..bb5d72bacee 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -155,7 +155,8 @@ object MillCliConfigParser { val customDoc = """ Usage: mill [options] task [task-options] [+ task ...] """ - val cheatSheet = """ + val cheatSheet = + """ task cheat sheet: mill resolve _ # see all top-level tasks and modules mill resolve __.compile # see all `compile` tasks in any module (recursively) diff --git a/scalalib/test/src/mill/scalalib/TestModuleUtilTests.scala b/scalalib/test/src/mill/scalalib/TestModuleUtilTests.scala index 730b4b7dac0..cae370075e9 100644 --- a/scalalib/test/src/mill/scalalib/TestModuleUtilTests.scala +++ b/scalalib/test/src/mill/scalalib/TestModuleUtilTests.scala @@ -254,6 +254,7 @@ object TestModuleUtilTests extends TestSuite { ) ) } + // format: off test("multi test suites") - { val expectedReport = @@ -293,6 +294,7 @@ object TestModuleUtilTests extends TestSuite { ) } + // format: on test("collapseTestClassNames") { val res = TestModuleUtil.collapseTestClassNames( Seq(