From 67e6af8f6a51e76bf6005cedf87c37daf043d324 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 20 Jul 2024 22:16:04 +0800 Subject: [PATCH 01/15] . --- scalalib/src/mill/scalalib/TestModule.scala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scalalib/src/mill/scalalib/TestModule.scala b/scalalib/src/mill/scalalib/TestModule.scala index 4b539b463aa..4a290c7b906 100644 --- a/scalalib/src/mill/scalalib/TestModule.scala +++ b/scalalib/src/mill/scalalib/TestModule.scala @@ -242,8 +242,8 @@ object TestModule { */ trait TestNg extends TestModule { override def testFramework: T[String] = "mill.testng.TestNGFramework" - override def ivyDeps: T[Agg[Dep]] = T { - super.ivyDeps() ++ Agg( + override def mandatoryIvyDeps: T[Agg[Dep]] = T { + super.mandatoryIvyDeps() ++ Agg( ivy"com.lihaoyi:mill-contrib-testng:${mill.api.BuildInfo.millVersion}" ) } @@ -255,8 +255,8 @@ object TestModule { */ trait Junit4 extends TestModule { override def testFramework: T[String] = "com.novocode.junit.JUnitFramework" - override def ivyDeps: T[Agg[Dep]] = T { - super.ivyDeps() ++ Agg(ivy"com.novocode:junit-interface:0.11") + override def mandatoryIvyDeps: T[Agg[Dep]] = T { + super.mandatoryIvyDeps() ++ Agg(ivy"com.novocode:junit-interface:0.11") } } @@ -266,8 +266,8 @@ object TestModule { */ trait Junit5 extends TestModule { override def testFramework: T[String] = "net.aichler.jupiter.api.JupiterFramework" - override def ivyDeps: T[Agg[Dep]] = T { - super.ivyDeps() ++ Agg(ivy"net.aichler:jupiter-interface:0.9.0") + override def mandatoryIvyDeps: T[Agg[Dep]] = T { + super.mandatoryIvyDeps() ++ Agg(ivy"net.aichler:jupiter-interface:0.9.0") } } From 2346b964da9dc8abdd7a8c8411d721622f0a333e Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 20 Jul 2024 22:16:55 +0800 Subject: [PATCH 02/15] . --- example/basicjava/1-simple/build.sc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/basicjava/1-simple/build.sc b/example/basicjava/1-simple/build.sc index 3a0cb29d168..a6d4a100f48 100644 --- a/example/basicjava/1-simple/build.sc +++ b/example/basicjava/1-simple/build.sc @@ -9,7 +9,7 @@ object foo extends RootModule with JavaModule { ) object test extends JavaModuleTests with TestModule.Junit4{ - def ivyDeps = super.ivyDeps() ++ Agg( + def ivyDeps = Agg( ivy"com.google.guava:guava:33.2.1-jre" ) } From 4e6862d19b11e99c4ea2cd79b146bcea7ab974a8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 20 Jul 2024 22:19:08 +0800 Subject: [PATCH 03/15] . --- example/basicjava/1-simple/build.sc | 2 +- example/basicjava/3-multi-module/build.sc | 2 +- example/basicjava/4-builtin-commands/build.sc | 2 +- example/javabuilds/5-test-suite/build.sc | 8 ++++---- example/javabuilds/9-realistic/build.sc | 2 +- example/javamodule/4-test-deps/build.sc | 4 ++-- scalalib/src/mill/scalalib/JavaModule.scala | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/example/basicjava/1-simple/build.sc b/example/basicjava/1-simple/build.sc index a6d4a100f48..747e87882f5 100644 --- a/example/basicjava/1-simple/build.sc +++ b/example/basicjava/1-simple/build.sc @@ -8,7 +8,7 @@ object foo extends RootModule with JavaModule { ivy"org.apache.commons:commons-text:1.12.0" ) - object test extends JavaModuleTests with TestModule.Junit4{ + object test extends JavaTests with TestModule.Junit4{ def ivyDeps = Agg( ivy"com.google.guava:guava:33.2.1-jre" ) diff --git a/example/basicjava/3-multi-module/build.sc b/example/basicjava/3-multi-module/build.sc index 5397b6c420a..f499b835c2d 100644 --- a/example/basicjava/3-multi-module/build.sc +++ b/example/basicjava/3-multi-module/build.sc @@ -3,7 +3,7 @@ import mill._, javalib._ trait MyModule extends JavaModule{ - object test extends JavaModuleTests with TestModule.Junit4 + object test extends JavaTests with TestModule.Junit4 } object foo extends MyModule{ diff --git a/example/basicjava/4-builtin-commands/build.sc b/example/basicjava/4-builtin-commands/build.sc index 922f80b7936..4c5bd57ae97 100644 --- a/example/basicjava/4-builtin-commands/build.sc +++ b/example/basicjava/4-builtin-commands/build.sc @@ -2,7 +2,7 @@ import mill._, javalib._ trait MyModule extends JavaModule{ - object test extends JavaModuleTests with TestModule.Junit4 + object test extends JavaTests with TestModule.Junit4 } object foo extends MyModule{ diff --git a/example/javabuilds/5-test-suite/build.sc b/example/javabuilds/5-test-suite/build.sc index eab63a07f71..fdf858024b4 100644 --- a/example/javabuilds/5-test-suite/build.sc +++ b/example/javabuilds/5-test-suite/build.sc @@ -2,7 +2,7 @@ import mill._, javalib._ object foo extends JavaModule { - object test extends JavaModuleTests { + object test extends JavaTests { def testFramework = "com.novocode.junit.JUnitFramework" def ivyDeps = T { super.ivyDeps() ++ Agg(ivy"com.novocode:junit-interface:0.11") @@ -13,11 +13,11 @@ object foo extends JavaModule { //// SNIPPET:BUILD2 object bar extends JavaModule { - object test extends JavaModuleTests with TestModule.Junit4 + object test extends JavaTests with TestModule.Junit4 } //// SNIPPET:BUILD3 object qux extends JavaModule { - object test extends JavaModuleTests with TestModule.Junit4 - object integration extends JavaModuleTests with TestModule.Junit4 + object test extends JavaTests with TestModule.Junit4 + object integration extends JavaTests with TestModule.Junit4 } diff --git a/example/javabuilds/9-realistic/build.sc b/example/javabuilds/9-realistic/build.sc index 6a841839866..5c5e00b9cf3 100644 --- a/example/javabuilds/9-realistic/build.sc +++ b/example/javabuilds/9-realistic/build.sc @@ -15,7 +15,7 @@ trait MyModule extends JavaModule with PublishModule { def ivyDeps = Agg(ivy"org.apache.commons:commons-text:1.12.0") - object test extends JavaModuleTests with TestModule.Junit4 + object test extends JavaTests with TestModule.Junit4 } object foo extends MyModule { diff --git a/example/javamodule/4-test-deps/build.sc b/example/javamodule/4-test-deps/build.sc index 59598bd83e8..800f354676e 100644 --- a/example/javamodule/4-test-deps/build.sc +++ b/example/javamodule/4-test-deps/build.sc @@ -5,12 +5,12 @@ import mill._, javalib._ object qux extends JavaModule { def moduleDeps = Seq(baz) - object test extends JavaModuleTests with TestModule.Junit4 { + object test extends JavaTests with TestModule.Junit4 { def moduleDeps = super.moduleDeps ++ Seq(baz.test) } } object baz extends JavaModule { - object test extends JavaModuleTests with TestModule.Junit4 + object test extends JavaTests with TestModule.Junit4 } diff --git a/scalalib/src/mill/scalalib/JavaModule.scala b/scalalib/src/mill/scalalib/JavaModule.scala index 2bf618462d9..be7c4c3785d 100644 --- a/scalalib/src/mill/scalalib/JavaModule.scala +++ b/scalalib/src/mill/scalalib/JavaModule.scala @@ -36,7 +36,7 @@ trait JavaModule with SemanticDbJavaModule { outer => def zincWorker: ModuleRef[ZincWorkerModule] = super.zincWorker - + type JavaTests = JavaModuleTests trait JavaModuleTests extends JavaModule with TestModule { // Run some consistence checks hierarchyChecks() From b1121c92fe59bec8a0fbc33502c6d5c89aa17e90 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 20 Jul 2024 22:20:33 +0800 Subject: [PATCH 04/15] . --- scalalib/src/mill/scalalib/CrossSbtModule.scala | 2 ++ scalalib/src/mill/scalalib/MavenModule.scala | 1 + scalalib/src/mill/scalalib/SbtModule.scala | 1 + 3 files changed, 4 insertions(+) diff --git a/scalalib/src/mill/scalalib/CrossSbtModule.scala b/scalalib/src/mill/scalalib/CrossSbtModule.scala index f2a140e99a9..180e994fd30 100644 --- a/scalalib/src/mill/scalalib/CrossSbtModule.scala +++ b/scalalib/src/mill/scalalib/CrossSbtModule.scala @@ -11,6 +11,8 @@ trait CrossSbtModule extends SbtModule with CrossModuleBase { outer => PathRef(millSourcePath / "src" / "main" / s"scala-$s") ) } + + type CrossSbtTests = CrossSbtModuleTests trait CrossSbtModuleTests extends SbtModuleTests { override def millSourcePath = outer.millSourcePath override def sources = T.sources { diff --git a/scalalib/src/mill/scalalib/MavenModule.scala b/scalalib/src/mill/scalalib/MavenModule.scala index 55c71301ff1..9c2c7b619b5 100644 --- a/scalalib/src/mill/scalalib/MavenModule.scala +++ b/scalalib/src/mill/scalalib/MavenModule.scala @@ -16,6 +16,7 @@ trait MavenModule extends JavaModule { outer => millSourcePath / "src" / "main" / "resources" } + type MavenTests = MavenModuleTests trait MavenModuleTests extends JavaModuleTests { override def millSourcePath = outer.millSourcePath override def intellijModulePath: os.Path = outer.millSourcePath / "src" / "test" diff --git a/scalalib/src/mill/scalalib/SbtModule.scala b/scalalib/src/mill/scalalib/SbtModule.scala index b054df31bd0..f4a81cc851a 100644 --- a/scalalib/src/mill/scalalib/SbtModule.scala +++ b/scalalib/src/mill/scalalib/SbtModule.scala @@ -12,6 +12,7 @@ trait SbtModule extends ScalaModule with MavenModule { millSourcePath / "src" / "main" / "java" ) + type SbtTests = SbtModuleTests trait SbtModuleTests extends ScalaTests with MavenModuleTests { override def sources = T.sources( millSourcePath / "src" / "test" / "scala", From 7c515b8b1bef16c9350478e111f403951732fa5a Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 20 Jul 2024 22:21:31 +0800 Subject: [PATCH 05/15] . --- build.sc | 2 +- example/javabuilds/8-compat-modules/build.sc | 2 +- example/scalabuilds/8-compat-modules/build.sc | 4 ++-- example/thirdparty/commons-io/build.sc | 2 +- example/thirdparty/jimfs/build.sc | 2 +- integration/feature/docannotations/repo/build.sc | 2 +- scalalib/src/mill/scalalib/SbtModule.scala | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build.sc b/build.sc index dab0238e412..05fe745feb3 100644 --- a/build.sc +++ b/build.sc @@ -724,7 +724,7 @@ object main extends MillStableScalaModule with BuildInfo { def buildInfoMembers = Seq(BuildInfo.Value("millVersion", millVersion(), "Mill version.")) def ivyDeps = Agg(Deps.junixsocket) - object test extends JavaModuleTests with TestModule.Junit4 { + object test extends JavaTests with TestModule.Junit4 { def ivyDeps = Agg(Deps.junitInterface, Deps.lambdaTest) } } diff --git a/example/javabuilds/8-compat-modules/build.sc b/example/javabuilds/8-compat-modules/build.sc index 9c98ae927f1..337606ca904 100644 --- a/example/javabuilds/8-compat-modules/build.sc +++ b/example/javabuilds/8-compat-modules/build.sc @@ -2,7 +2,7 @@ import mill._, javalib._ object foo extends MavenModule { - object test extends MavenModuleTests with TestModule.Junit4 + object test extends MavenTests with TestModule.Junit4 } diff --git a/example/scalabuilds/8-compat-modules/build.sc b/example/scalabuilds/8-compat-modules/build.sc index 3de51bae93a..98efff5b561 100644 --- a/example/scalabuilds/8-compat-modules/build.sc +++ b/example/scalabuilds/8-compat-modules/build.sc @@ -3,7 +3,7 @@ import mill._, scalalib._ object foo extends SbtModule { def scalaVersion = "2.13.8" - object test extends SbtModuleTests { + object test extends SbtTests { def ivyDeps = Agg(ivy"com.lihaoyi::utest:0.7.11") def testFramework = "utest.runner.Framework" } @@ -12,7 +12,7 @@ object foo extends SbtModule { object bar extends Cross[BarModule]("2.12.17", "2.13.8") trait BarModule extends CrossSbtModule { - object test extends CrossSbtModuleTests { + object test extends CrossSbtTests { def ivyDeps = Agg(ivy"com.lihaoyi::utest:0.7.11") def testFramework = "utest.runner.Framework" } diff --git a/example/thirdparty/commons-io/build.sc b/example/thirdparty/commons-io/build.sc index 143e60dac5f..34097510b6f 100644 --- a/example/thirdparty/commons-io/build.sc +++ b/example/thirdparty/commons-io/build.sc @@ -14,7 +14,7 @@ object commonsio extends RootModule with PublishModule with MavenModule { developers = Nil ) - object test extends MavenModuleTests with TestModule.Junit5 with JmhModule{ + object test extends MavenTests with TestModule.Junit5 with JmhModule{ def jmhCoreVersion = "1.37" def ivyDeps = super.ivyDeps() ++ Agg( ivy"org.junit.jupiter:junit-jupiter:5.10.3", diff --git a/example/thirdparty/jimfs/build.sc b/example/thirdparty/jimfs/build.sc index 00efc46254c..440aafab7ca 100644 --- a/example/thirdparty/jimfs/build.sc +++ b/example/thirdparty/jimfs/build.sc @@ -28,7 +28,7 @@ object jimfs extends PublishModule with MavenModule { def javacOptions = Seq("-processor", "com.google.auto.service.processor.AutoServiceProcessor") - object test extends MavenModuleTests { + object test extends MavenTests { def ivyDeps = sharedCompileIvyDeps() ++ Agg( ivy"junit:junit:4.13.2", ivy"com.google.guava:guava-testlib:31.1-android", diff --git a/integration/feature/docannotations/repo/build.sc b/integration/feature/docannotations/repo/build.sc index 959b171777d..cbe16e5a5fe 100644 --- a/integration/feature/docannotations/repo/build.sc +++ b/integration/feature/docannotations/repo/build.sc @@ -16,7 +16,7 @@ trait JUnitTests extends TestModule.Junit4 { * The Core Module Docz! */ object core extends JavaModule { - object test extends JavaModuleTests with JUnitTests + object test extends JavaTests with JUnitTests /** * Core Target Docz! diff --git a/scalalib/src/mill/scalalib/SbtModule.scala b/scalalib/src/mill/scalalib/SbtModule.scala index f4a81cc851a..027abc18be4 100644 --- a/scalalib/src/mill/scalalib/SbtModule.scala +++ b/scalalib/src/mill/scalalib/SbtModule.scala @@ -13,7 +13,7 @@ trait SbtModule extends ScalaModule with MavenModule { ) type SbtTests = SbtModuleTests - trait SbtModuleTests extends ScalaTests with MavenModuleTests { + trait SbtModuleTests extends ScalaTests with MavenTests { override def sources = T.sources( millSourcePath / "src" / "test" / "scala", millSourcePath / "src" / "test" / "java" From 745a83dbb0678639e0f62f74224a5b025ee9f6b3 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 21 Jul 2024 08:51:38 +0800 Subject: [PATCH 06/15] . --- build.sc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sc b/build.sc index 05fe745feb3..dab0238e412 100644 --- a/build.sc +++ b/build.sc @@ -724,7 +724,7 @@ object main extends MillStableScalaModule with BuildInfo { def buildInfoMembers = Seq(BuildInfo.Value("millVersion", millVersion(), "Mill version.")) def ivyDeps = Agg(Deps.junixsocket) - object test extends JavaTests with TestModule.Junit4 { + object test extends JavaModuleTests with TestModule.Junit4 { def ivyDeps = Agg(Deps.junitInterface, Deps.lambdaTest) } } From a6ea33f753c5f43bf76e6128368f96fbd4b1f6e7 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 21 Jul 2024 08:59:00 +0800 Subject: [PATCH 07/15] . --- example/basicjava/1-simple/test/src/FooTest.java | 3 ++- scalalib/src/mill/scalalib/TestModule.scala | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/example/basicjava/1-simple/test/src/FooTest.java b/example/basicjava/1-simple/test/src/FooTest.java index 41571709223..80f730a8735 100644 --- a/example/basicjava/1-simple/test/src/FooTest.java +++ b/example/basicjava/1-simple/test/src/FooTest.java @@ -1,5 +1,6 @@ package foo; import static org.junit.Assert.assertEquals; +import static com.google.common.html.HtmlEscapers.htmlEscaper; import org.junit.Test; public class FooTest { @@ -10,6 +11,6 @@ public void testSimple() { @Test public void testEscaping() { - assertEquals(Foo.generateHtml(""), "

<hello>

"); + assertEquals(Foo.generateHtml(""), "

" + htmlEscaper().escape("") + "

"); } } diff --git a/scalalib/src/mill/scalalib/TestModule.scala b/scalalib/src/mill/scalalib/TestModule.scala index 4a290c7b906..3b771d666bb 100644 --- a/scalalib/src/mill/scalalib/TestModule.scala +++ b/scalalib/src/mill/scalalib/TestModule.scala @@ -240,7 +240,7 @@ object TestModule { * TestModule using TestNG Framework to run tests. * You need to provide the testng dependency yourself. */ - trait TestNg extends TestModule { + trait TestNg extends JavaModuleBase with TestModule { override def testFramework: T[String] = "mill.testng.TestNGFramework" override def mandatoryIvyDeps: T[Agg[Dep]] = T { super.mandatoryIvyDeps() ++ Agg( @@ -253,7 +253,7 @@ object TestModule { * TestModule that uses JUnit 4 Framework to run tests. * You may want to provide the junit dependency explicitly to use another version. */ - trait Junit4 extends TestModule { + trait Junit4 extends JavaModuleBase with TestModule { override def testFramework: T[String] = "com.novocode.junit.JUnitFramework" override def mandatoryIvyDeps: T[Agg[Dep]] = T { super.mandatoryIvyDeps() ++ Agg(ivy"com.novocode:junit-interface:0.11") @@ -264,7 +264,7 @@ object TestModule { * TestModule that uses JUnit 5 Framework to run tests. * You may want to provide the junit dependency explicitly to use another version. */ - trait Junit5 extends TestModule { + trait Junit5 extends JavaModuleBase with TestModule { override def testFramework: T[String] = "net.aichler.jupiter.api.JupiterFramework" override def mandatoryIvyDeps: T[Agg[Dep]] = T { super.mandatoryIvyDeps() ++ Agg(ivy"net.aichler:jupiter-interface:0.9.0") @@ -374,6 +374,7 @@ object TestModule { trait JavaModuleBase extends BspModule { def ivyDeps: T[Agg[Dep]] = Agg.empty[Dep] + def mandatoryIvyDeps: T[Agg[Dep]] = Agg.empty[Dep] } trait ScalaModuleBase extends mill.Module { From 4bae0b879c979c8e29358a16f96a357a43422227 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 21 Jul 2024 09:13:31 +0800 Subject: [PATCH 08/15] . --- .../ROOT/pages/Intro_to_Mill_for_Java.adoc | 20 +++++++++++++++++++ .../ROOT/pages/Intro_to_Mill_for_Scala.adoc | 11 ++++++++++ .../ROOT/partials/Intro_to_Mill_Header.adoc | 6 +++--- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/docs/modules/ROOT/pages/Intro_to_Mill_for_Java.adoc b/docs/modules/ROOT/pages/Intro_to_Mill_for_Java.adoc index 5dff93ddc3b..aac37a7b96b 100644 --- a/docs/modules/ROOT/pages/Intro_to_Mill_for_Java.adoc +++ b/docs/modules/ROOT/pages/Intro_to_Mill_for_Java.adoc @@ -14,6 +14,26 @@ = Introduction to Mill for Java + +{mill-github-url}[Mill] is your shiny new Java build tool! Mill aims for +simplicity by reusing concepts you are already familiar with, borrowing ideas +from modern tools like https://maven.apache.org/[Maven], https://gradle.org/[Gradle], +https://bazel.build/[Bazel]. It lets you build +your projects in a way that's simple, fast, and predictable. + +Compared to Maven and Gradle, Mill builds are far more intuitive and easy to read and write: + +* **Mill builds are an order of magnitude more concise than Maven pom.xml files**: this makes + them both easy to write and easy to read at a glance + +* **Mill builds are easy to extend by non-experts**: anyone can extend a Mill build + with a few lines of code, without needing to learn a complicated plugin framework, + allowing end users the freedom to fit their build logic to their own unique requirements + +* **Mill builds are familiar to anyone who knows programming**: rather than scopes, lifecycles, + or phases, Mill builds on top of objects, methods, inheritance, and overrides: concepts + immediately familiar to any Java programmer + include::partial$Intro_to_Mill_Header.adoc[] diff --git a/docs/modules/ROOT/pages/Intro_to_Mill_for_Scala.adoc b/docs/modules/ROOT/pages/Intro_to_Mill_for_Scala.adoc index 5172a670695..2bdb0b51557 100644 --- a/docs/modules/ROOT/pages/Intro_to_Mill_for_Scala.adoc +++ b/docs/modules/ROOT/pages/Intro_to_Mill_for_Scala.adoc @@ -15,6 +15,17 @@ :page-aliases: index.adoc +Mill is far easier to understand, maintain, and extend than other Scala build tools +like SBT. Mill leverages concepts you already know: objects, methods, inheritance and +overrides, meaning that any Scala programmer can start using Mill and immediately know +how things work. + +If you are coming from a SBT background, the following blog posts discuss some of the +fundamental design issues with SBT, and how Mill attempts to do better: + +- https://www.lihaoyi.com/post/SowhatswrongwithSBT.html[So, what's wrong with SBT?] +- https://www.lihaoyi.com/post/MillBetterScalaBuilds.html[Mill: Better Scala Builds] + include::partial$Intro_to_Mill_Header.adoc[] diff --git a/docs/modules/ROOT/partials/Intro_to_Mill_Header.adoc b/docs/modules/ROOT/partials/Intro_to_Mill_Header.adoc index 34c6c6d2e82..481c01d8c5a 100644 --- a/docs/modules/ROOT/partials/Intro_to_Mill_Header.adoc +++ b/docs/modules/ROOT/partials/Intro_to_Mill_Header.adoc @@ -14,8 +14,8 @@ Mill has built-in support for the Java and https://www.scala-lang.org/[Scala] programming language, and can serve as a replacement for https://maven.apache.org/[Maven], https://gradle.org/[Gradle], or http://www.scala-sbt.org/[SBT]. It can be xref:Extending_Mill.adoc[extended] -to support any other language or platform via modules (written in Java -or Scala) or through external subprocesses. Mill supports a rich ecosystem of +to support any other language or platform via modules or through +external subprocesses. Mill supports a rich ecosystem of xref:Contrib_Plugins.adoc[] and xref:Thirdparty_Plugins.adoc[]. If you are using Mill, you will find the following book by the Author useful in @@ -31,6 +31,6 @@ all about: - https://www.lihaoyi.com/post/SoWhatsSoSpecialAboutTheMillScalaBuildTool.html[Blog Post: So, What's So Special About The Mill Scala Build Tool?] The rest of this page contains a quick introduction to getting start with using -Mill to build a simple Scala program. The other pages of this doc-site go into +Mill to build a simple program. The other pages of this doc-site go into more depth, with more examples of how to use Mill and more details of how the Mill build tool works. From e694511655fbfd2c18d18cd7b2d9fe185371942a Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 21 Jul 2024 09:35:50 +0800 Subject: [PATCH 09/15] . --- .../ROOT/pages/Intro_to_Mill_for_Java.adoc | 18 +++++------- .../ROOT/pages/Intro_to_Mill_for_Scala.adoc | 29 ++++++++++++++----- .../ROOT/partials/Intro_to_Mill_Header.adoc | 27 +++++------------ 3 files changed, 38 insertions(+), 36 deletions(-) diff --git a/docs/modules/ROOT/pages/Intro_to_Mill_for_Java.adoc b/docs/modules/ROOT/pages/Intro_to_Mill_for_Java.adoc index aac37a7b96b..0694943860d 100644 --- a/docs/modules/ROOT/pages/Intro_to_Mill_for_Java.adoc +++ b/docs/modules/ROOT/pages/Intro_to_Mill_for_Java.adoc @@ -18,22 +18,20 @@ {mill-github-url}[Mill] is your shiny new Java build tool! Mill aims for simplicity by reusing concepts you are already familiar with, borrowing ideas from modern tools like https://maven.apache.org/[Maven], https://gradle.org/[Gradle], -https://bazel.build/[Bazel]. It lets you build +https://bazel.build/[Bazel]. Mill lets you build and customize your projects in a way that's simple, fast, and predictable. -Compared to Maven and Gradle, Mill builds are far more intuitive and easy to read and write: +Mill automates dealing with a lot of common build-tool concerns such as caching, +incremental re-computation, and parallelism. This allows you +to focus your effort on the business logic unique to your build, while letting +Mill take care of all the rest. + +Compared to Maven and Gradle, Mill builds are far more intuitive and easy to read, +write, and debug: * **Mill builds are an order of magnitude more concise than Maven pom.xml files**: this makes them both easy to write and easy to read at a glance -* **Mill builds are easy to extend by non-experts**: anyone can extend a Mill build - with a few lines of code, without needing to learn a complicated plugin framework, - allowing end users the freedom to fit their build logic to their own unique requirements - -* **Mill builds are familiar to anyone who knows programming**: rather than scopes, lifecycles, - or phases, Mill builds on top of objects, methods, inheritance, and overrides: concepts - immediately familiar to any Java programmer - include::partial$Intro_to_Mill_Header.adoc[] diff --git a/docs/modules/ROOT/pages/Intro_to_Mill_for_Scala.adoc b/docs/modules/ROOT/pages/Intro_to_Mill_for_Scala.adoc index 2bdb0b51557..b908304c91d 100644 --- a/docs/modules/ROOT/pages/Intro_to_Mill_for_Scala.adoc +++ b/docs/modules/ROOT/pages/Intro_to_Mill_for_Scala.adoc @@ -15,18 +15,33 @@ :page-aliases: index.adoc -Mill is far easier to understand, maintain, and extend than other Scala build tools -like SBT. Mill leverages concepts you already know: objects, methods, inheritance and -overrides, meaning that any Scala programmer can start using Mill and immediately know -how things work. -If you are coming from a SBT background, the following blog posts discuss some of the -fundamental design issues with SBT, and how Mill attempts to do better: +{mill-github-url}[Mill] is your shiny new Scala build tool! Mill aims for +simplicity by reusing concepts you are already familiar with, borrowing ideas +from modern tools like https://maven.apache.org/[Maven], https://gradle.org/[Gradle], +https://bazel.build/[Bazel] and https://www.scala-sbt.org/[SBT]. Mill lets you build +and customize your projects in a way that's simple, fast, and predictable. + +Mill automates dealing with a lot of common build-tool concerns such as caching, +incremental re-computation, and parallelism. This allows you +to focus your effort on the business logic unique to your build, while letting +Mill take care of all the rest. + +Compared to SBT and other tools, Mill builds are far more intuitive and easy to read, +write, and debug: + +include::partial$Intro_to_Mill_Header.adoc[] + +The following blog posts discuss some of the fundamental design issues with SBT, and +how Mill attempts to do better: - https://www.lihaoyi.com/post/SowhatswrongwithSBT.html[So, what's wrong with SBT?] - https://www.lihaoyi.com/post/MillBetterScalaBuilds.html[Mill: Better Scala Builds] -include::partial$Intro_to_Mill_Header.adoc[] +If you are using Mill, you will find the following book by the Author useful in +using Mill and its supporting libraries to the fullest: + +* https://handsonscala.com/[Hands-on Scala Programming] == Simple Scala Module diff --git a/docs/modules/ROOT/partials/Intro_to_Mill_Header.adoc b/docs/modules/ROOT/partials/Intro_to_Mill_Header.adoc index 481c01d8c5a..f82d8ef6f7c 100644 --- a/docs/modules/ROOT/partials/Intro_to_Mill_Header.adoc +++ b/docs/modules/ROOT/partials/Intro_to_Mill_Header.adoc @@ -1,34 +1,23 @@ -{mill-github-url}[Mill] is your shiny new Java/Scala build tool! Mill aims for -simplicity by reusing concepts you are already familiar with, borrowing ideas -from modern tools like https://maven.apache.org/[Maven], https://gradle.org/[Gradle], -https://bazel.build/[Bazel] and https://www.scala-sbt.org/[SBT]. It lets you build -your projects in a way that's simple, fast, and predictable. +* **Mill builds are easy to extend by non-experts**: anyone can extend a Mill build +with a few lines of code, without needing to learn a complicated plugin framework, +allowing end users the freedom to fit their build logic to their own unique requirements -Mill automates dealing with a lot of common build-tool concerns: Caching, -incremental re-computation, parallelism, discoverability, etc. This allows you -to focus your effort on the business logic unique to your build, while letting -Mill take care of all the rest. +* **Mill builds are familiar to anyone who knows programming**: rather than scopes, lifecycles, +or phases, Mill builds on top of objects, methods, inheritance, and overrides: concepts +immediately familiar to any Java programmer -Mill has built-in support for the Java and https://www.scala-lang.org/[Scala] -programming language, and can serve as a replacement for -https://maven.apache.org/[Maven], https://gradle.org/[Gradle], or -http://www.scala-sbt.org/[SBT]. It can be xref:Extending_Mill.adoc[extended] +Mill can be xref:Extending_Mill.adoc[extended] to support any other language or platform via modules or through external subprocesses. Mill supports a rich ecosystem of xref:Contrib_Plugins.adoc[] and xref:Thirdparty_Plugins.adoc[]. -If you are using Mill, you will find the following book by the Author useful in -using Mill and its supporting libraries to the fullest: - -* https://handsonscala.com/[Hands-on Scala Programming] - If you prefer a video introduction rather than text, the following presentation (and companion blog post) is a good introduction into what the Mill build tool is all about: - https://www.youtube.com/watch?v=UsXgCeU-ovI&list=PLLMLOC3WM2r6ZFhFfVH74W-sl8LfWtOEc&index=15[Video: A Deep Dive into the Mill Build Tool] -- https://www.lihaoyi.com/post/SoWhatsSoSpecialAboutTheMillScalaBuildTool.html[Blog Post: So, What's So Special About The Mill Scala Build Tool?] +- https://www.lihaoyi.com/post/SoWhatsSoSpecialAboutTheMillScalaBuildTool.html[Blog Post: What's So Special About The Mill Scala Build Tool?] The rest of this page contains a quick introduction to getting start with using Mill to build a simple program. The other pages of this doc-site go into From 3a5e48fbd64a743c5ac1585d4ebcda37fcd6eefc Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 21 Jul 2024 10:32:13 +0800 Subject: [PATCH 10/15] . --- example/basicjava/1-simple/build.sc | 2 +- scalalib/src/mill/scalalib/TestModule.scala | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/example/basicjava/1-simple/build.sc b/example/basicjava/1-simple/build.sc index 747e87882f5..6526bc27cdd 100644 --- a/example/basicjava/1-simple/build.sc +++ b/example/basicjava/1-simple/build.sc @@ -9,7 +9,7 @@ object foo extends RootModule with JavaModule { ) object test extends JavaTests with TestModule.Junit4{ - def ivyDeps = Agg( + def ivyDeps = super.ivyDeps() ++ Agg( ivy"com.google.guava:guava:33.2.1-jre" ) } diff --git a/scalalib/src/mill/scalalib/TestModule.scala b/scalalib/src/mill/scalalib/TestModule.scala index 3b771d666bb..4b539b463aa 100644 --- a/scalalib/src/mill/scalalib/TestModule.scala +++ b/scalalib/src/mill/scalalib/TestModule.scala @@ -240,10 +240,10 @@ object TestModule { * TestModule using TestNG Framework to run tests. * You need to provide the testng dependency yourself. */ - trait TestNg extends JavaModuleBase with TestModule { + trait TestNg extends TestModule { override def testFramework: T[String] = "mill.testng.TestNGFramework" - override def mandatoryIvyDeps: T[Agg[Dep]] = T { - super.mandatoryIvyDeps() ++ Agg( + override def ivyDeps: T[Agg[Dep]] = T { + super.ivyDeps() ++ Agg( ivy"com.lihaoyi:mill-contrib-testng:${mill.api.BuildInfo.millVersion}" ) } @@ -253,10 +253,10 @@ object TestModule { * TestModule that uses JUnit 4 Framework to run tests. * You may want to provide the junit dependency explicitly to use another version. */ - trait Junit4 extends JavaModuleBase with TestModule { + trait Junit4 extends TestModule { override def testFramework: T[String] = "com.novocode.junit.JUnitFramework" - override def mandatoryIvyDeps: T[Agg[Dep]] = T { - super.mandatoryIvyDeps() ++ Agg(ivy"com.novocode:junit-interface:0.11") + override def ivyDeps: T[Agg[Dep]] = T { + super.ivyDeps() ++ Agg(ivy"com.novocode:junit-interface:0.11") } } @@ -264,10 +264,10 @@ object TestModule { * TestModule that uses JUnit 5 Framework to run tests. * You may want to provide the junit dependency explicitly to use another version. */ - trait Junit5 extends JavaModuleBase with TestModule { + trait Junit5 extends TestModule { override def testFramework: T[String] = "net.aichler.jupiter.api.JupiterFramework" - override def mandatoryIvyDeps: T[Agg[Dep]] = T { - super.mandatoryIvyDeps() ++ Agg(ivy"net.aichler:jupiter-interface:0.9.0") + override def ivyDeps: T[Agg[Dep]] = T { + super.ivyDeps() ++ Agg(ivy"net.aichler:jupiter-interface:0.9.0") } } @@ -374,7 +374,6 @@ object TestModule { trait JavaModuleBase extends BspModule { def ivyDeps: T[Agg[Dep]] = Agg.empty[Dep] - def mandatoryIvyDeps: T[Agg[Dep]] = Agg.empty[Dep] } trait ScalaModuleBase extends mill.Module { From 2a435996ceb1e7b58b1a83a0556a9e40e301e066 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 22 Jul 2024 16:21:09 +0800 Subject: [PATCH 11/15] . --- .config/mill-version | 3 ++- scalalib/src/mill/scalalib/JavaModule.scala | 1 + scalalib/src/mill/scalalib/MavenModule.scala | 1 + scalalib/src/mill/scalalib/SbtModule.scala | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.config/mill-version b/.config/mill-version index f91669574c9..12a3c43b52d 100644 --- a/.config/mill-version +++ b/.config/mill-version @@ -1 +1,2 @@ -0.11.7-17-17dea9 +0.11.9-7-54679f + diff --git a/scalalib/src/mill/scalalib/JavaModule.scala b/scalalib/src/mill/scalalib/JavaModule.scala index be7c4c3785d..cda51f3105c 100644 --- a/scalalib/src/mill/scalalib/JavaModule.scala +++ b/scalalib/src/mill/scalalib/JavaModule.scala @@ -37,6 +37,7 @@ trait JavaModule def zincWorker: ModuleRef[ZincWorkerModule] = super.zincWorker type JavaTests = JavaModuleTests + @deprecated("0.11.10, use JavaTests instead") trait JavaModuleTests extends JavaModule with TestModule { // Run some consistence checks hierarchyChecks() diff --git a/scalalib/src/mill/scalalib/MavenModule.scala b/scalalib/src/mill/scalalib/MavenModule.scala index 9c2c7b619b5..12395f47a98 100644 --- a/scalalib/src/mill/scalalib/MavenModule.scala +++ b/scalalib/src/mill/scalalib/MavenModule.scala @@ -17,6 +17,7 @@ trait MavenModule extends JavaModule { outer => } type MavenTests = MavenModuleTests + @deprecated("0.11.10, use MavenTests instead") trait MavenModuleTests extends JavaModuleTests { override def millSourcePath = outer.millSourcePath override def intellijModulePath: os.Path = outer.millSourcePath / "src" / "test" diff --git a/scalalib/src/mill/scalalib/SbtModule.scala b/scalalib/src/mill/scalalib/SbtModule.scala index 027abc18be4..bafb4242782 100644 --- a/scalalib/src/mill/scalalib/SbtModule.scala +++ b/scalalib/src/mill/scalalib/SbtModule.scala @@ -13,6 +13,7 @@ trait SbtModule extends ScalaModule with MavenModule { ) type SbtTests = SbtModuleTests + @deprecated("0.11.10, use SbtTests instead") trait SbtModuleTests extends ScalaTests with MavenTests { override def sources = T.sources( millSourcePath / "src" / "test" / "scala", From bd5e117b0f47fbb6c95fce15de56d9b826f8f57e Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 22 Jul 2024 17:29:10 +0800 Subject: [PATCH 12/15] . --- .config/mill-version | 3 +-- scalalib/src/mill/scalalib/CrossSbtModule.scala | 1 + scalalib/src/mill/scalalib/JavaModule.scala | 2 +- scalalib/src/mill/scalalib/MavenModule.scala | 2 +- scalalib/src/mill/scalalib/SbtModule.scala | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.config/mill-version b/.config/mill-version index 12a3c43b52d..f91669574c9 100644 --- a/.config/mill-version +++ b/.config/mill-version @@ -1,2 +1 @@ -0.11.9-7-54679f - +0.11.7-17-17dea9 diff --git a/scalalib/src/mill/scalalib/CrossSbtModule.scala b/scalalib/src/mill/scalalib/CrossSbtModule.scala index 180e994fd30..40f68ad574c 100644 --- a/scalalib/src/mill/scalalib/CrossSbtModule.scala +++ b/scalalib/src/mill/scalalib/CrossSbtModule.scala @@ -13,6 +13,7 @@ trait CrossSbtModule extends SbtModule with CrossModuleBase { outer => } type CrossSbtTests = CrossSbtModuleTests + @deprecated("Use CrossSbtTests instead", since = "Mill 0.11.10") trait CrossSbtModuleTests extends SbtModuleTests { override def millSourcePath = outer.millSourcePath override def sources = T.sources { diff --git a/scalalib/src/mill/scalalib/JavaModule.scala b/scalalib/src/mill/scalalib/JavaModule.scala index cda51f3105c..9b594c82039 100644 --- a/scalalib/src/mill/scalalib/JavaModule.scala +++ b/scalalib/src/mill/scalalib/JavaModule.scala @@ -37,7 +37,7 @@ trait JavaModule def zincWorker: ModuleRef[ZincWorkerModule] = super.zincWorker type JavaTests = JavaModuleTests - @deprecated("0.11.10, use JavaTests instead") + @deprecated("Use JavaTests instead", since = "Mill 0.11.10") trait JavaModuleTests extends JavaModule with TestModule { // Run some consistence checks hierarchyChecks() diff --git a/scalalib/src/mill/scalalib/MavenModule.scala b/scalalib/src/mill/scalalib/MavenModule.scala index 12395f47a98..80a7871c2bd 100644 --- a/scalalib/src/mill/scalalib/MavenModule.scala +++ b/scalalib/src/mill/scalalib/MavenModule.scala @@ -17,7 +17,7 @@ trait MavenModule extends JavaModule { outer => } type MavenTests = MavenModuleTests - @deprecated("0.11.10, use MavenTests instead") + @deprecated("Use JavaTests instead", since = "Mill 0.11.10") trait MavenModuleTests extends JavaModuleTests { override def millSourcePath = outer.millSourcePath override def intellijModulePath: os.Path = outer.millSourcePath / "src" / "test" diff --git a/scalalib/src/mill/scalalib/SbtModule.scala b/scalalib/src/mill/scalalib/SbtModule.scala index bafb4242782..be9bf0df839 100644 --- a/scalalib/src/mill/scalalib/SbtModule.scala +++ b/scalalib/src/mill/scalalib/SbtModule.scala @@ -13,7 +13,7 @@ trait SbtModule extends ScalaModule with MavenModule { ) type SbtTests = SbtModuleTests - @deprecated("0.11.10, use SbtTests instead") + @deprecated("Use SbtTests instead", since = "Mill 0.11.10") trait SbtModuleTests extends ScalaTests with MavenTests { override def sources = T.sources( millSourcePath / "src" / "test" / "scala", From d2dbfe95733b39f1837d7b3e0a3d72ef47ddc9b3 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 22 Jul 2024 17:35:05 +0800 Subject: [PATCH 13/15] . --- scalalib/src/mill/scalalib/RunModule.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scalalib/src/mill/scalalib/RunModule.scala b/scalalib/src/mill/scalalib/RunModule.scala index b87f596b6d0..20b841b8ed7 100644 --- a/scalalib/src/mill/scalalib/RunModule.scala +++ b/scalalib/src/mill/scalalib/RunModule.scala @@ -158,7 +158,7 @@ trait RunModule extends WithZincWorker { runUseArgsFile = runUseArgsFile(), backgroundOutputs = backgroundOutputs(T.dest) )(args().value: _*)(T.ctx()) - + // Make sure to sleep a bit in the Mill test suite to allow the servers we // start time to initialize before we proceed with the following commands if (T.env.contains("MILL_TEST_SUITE")) { From 3b8488c3053a01e443b305907521a3c0d272e934 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 22 Jul 2024 18:06:17 +0800 Subject: [PATCH 14/15] . --- .../subprocess-stdout/test/src/SubprocessStdoutTests.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/feature/subprocess-stdout/test/src/SubprocessStdoutTests.scala b/integration/feature/subprocess-stdout/test/src/SubprocessStdoutTests.scala index 958376340d9..6dc5b7fa5f3 100644 --- a/integration/feature/subprocess-stdout/test/src/SubprocessStdoutTests.scala +++ b/integration/feature/subprocess-stdout/test/src/SubprocessStdoutTests.scala @@ -58,7 +58,7 @@ object SubprocessStdoutTests extends IntegrationTestSuite { // up in the console somewhere and not disappear // val res2 = evalStdCombined("inheritRaw").out - if (integrationTestMode == "fork") { + if (integrationTestMode != "fork") { // For `fork` tests, which represent `-i`/`--interactive`/`--no-server`, the output should // be properly ordered since it all comes directly from the stdout/stderr of the same process assert( From bf1e612d19f394177b60f97922fcbbe0af17d10d Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 22 Jul 2024 18:06:41 +0800 Subject: [PATCH 15/15] . --- .../test/src/SubprocessStdoutTests.scala | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/integration/feature/subprocess-stdout/test/src/SubprocessStdoutTests.scala b/integration/feature/subprocess-stdout/test/src/SubprocessStdoutTests.scala index 6dc5b7fa5f3..dc76d37fe32 100644 --- a/integration/feature/subprocess-stdout/test/src/SubprocessStdoutTests.scala +++ b/integration/feature/subprocess-stdout/test/src/SubprocessStdoutTests.scala @@ -58,7 +58,7 @@ object SubprocessStdoutTests extends IntegrationTestSuite { // up in the console somewhere and not disappear // val res2 = evalStdCombined("inheritRaw").out - if (integrationTestMode != "fork") { + if (integrationTestMode == "fork") { // For `fork` tests, which represent `-i`/`--interactive`/`--no-server`, the output should // be properly ordered since it all comes directly from the stdout/stderr of the same process assert( @@ -70,15 +70,15 @@ object SubprocessStdoutTests extends IntegrationTestSuite { ) ) } else { - // Note that it should be out of order, because both `print`s will be captured and logged first, + // Note that it may be out of order, because both `print`s will be captured and logged first, // whereas the two `proc` outputs will get sent to their respective log files and only noticed // a few milliseconds later as the files are polled for updates assert( - res2.contains( - """print stdoutRaw - |print stderrRaw - |proc stdoutRaw - |proc stderrRaw""".stripMargin + """print stdoutRaw + |print stderrRaw + |proc stdoutRaw + |proc stderrRaw""".stripMargin.linesIterator.toSet.subsetOf( + res2.linesIterator.toSet ) ) }