diff --git a/bsp/worker/src/mill/bsp/worker/MillJavaBuildServer.scala b/bsp/worker/src/mill/bsp/worker/MillJavaBuildServer.scala index 4e43072beb5..e7b00993267 100644 --- a/bsp/worker/src/mill/bsp/worker/MillJavaBuildServer.scala +++ b/bsp/worker/src/mill/bsp/worker/MillJavaBuildServer.scala @@ -26,7 +26,13 @@ private trait MillJavaBuildServer extends JavaBuildServer { this: MillBuildServe sem.bspCompiledClassesAndSemanticDbFiles case _ => m.bspCompileClassesPath } - T.task { (classesPathTask(), m.javacOptions(), m.bspCompileClasspath()) } + T.task { + ( + classesPathTask(), + m.javacOptions() ++ m.mandatoryJavacOptions(), + m.bspCompileClasspath() + ) + } } ) { // We ignore all non-JavaModule diff --git a/build.mill b/build.mill index 967aed92b06..820784d4f1b 100644 --- a/build.mill +++ b/build.mill @@ -522,6 +522,11 @@ trait MillStableScalaModule extends MillPublishScalaModule with Mima { ), ProblemFilter.exclude[InheritedNewAbstractMethodProblem]( "mill.main.MainModule.mill$define$BaseModule0$_setter_$evalWatchedValues_=" + ), + + // https://github.com/com-lihaoyi/mill/pull/3503 + ProblemFilter.exclude[ReversedMissingMethodProblem]( + "mill.scalalib.ScalaModule#ScalaTests.mill$scalalib$ScalaModule$ScalaTests$$super$mandatoryScalacOptions" ) ) def mimaPreviousVersions: T[Seq[String]] = Settings.mimaBaseVersions @@ -875,7 +880,6 @@ object dist extends MillPublishJavaModule { } } - /** * Build and install Mill locally. * diff --git a/contrib/bloop/src/mill/contrib/bloop/BloopImpl.scala b/contrib/bloop/src/mill/contrib/bloop/BloopImpl.scala index 1327051c7af..2a930b2b4b0 100644 --- a/contrib/bloop/src/mill/contrib/bloop/BloopImpl.scala +++ b/contrib/bloop/src/mill/contrib/bloop/BloopImpl.scala @@ -161,8 +161,10 @@ class BloopImpl(evs: () => Seq[Evaluator], wd: os.Path) extends ExternalModule { def out(m: JavaModule) = bloopDir / "out" / name(m) def classes(m: JavaModule) = out(m) / "classes" - val javaConfig = - module.javacOptions.map(opts => Some(Config.Java(options = opts.toList))) + val javaConfig = T.task { + val opts = module.javacOptions() ++ module.mandatoryJavacOptions() + Some(Config.Java(options = opts.toList)) + } // ////////////////////////////////////////////////////////////////////////// // Scalac diff --git a/contrib/errorprone/src/mill/contrib/errorprone/ErrorProneModule.scala b/contrib/errorprone/src/mill/contrib/errorprone/ErrorProneModule.scala index ff51b5b4f70..c6e27f097dd 100644 --- a/contrib/errorprone/src/mill/contrib/errorprone/ErrorProneModule.scala +++ b/contrib/errorprone/src/mill/contrib/errorprone/ErrorProneModule.scala @@ -31,7 +31,7 @@ trait ErrorProneModule extends JavaModule { * The classpath of the `error-prone` compiler plugin. */ def errorProneClasspath: T[Agg[PathRef]] = T { - resolveDeps(T.task { errorProneDeps().map(bindDependency()) })() + defaultResolver().resolveDeps(errorProneDeps()) } /** @@ -70,12 +70,7 @@ trait ErrorProneModule extends JavaModule { /** * Appends the [[errorProneJavacEnableOptions]] to the Java compiler options. */ - override def javacOptions: T[Seq[String]] = T { - val supOpts = super.javacOptions() - val enableOpts = Option - .when(!supOpts.exists(o => o.startsWith("-Xplugin:ErrorProne")))( - errorProneJavacEnableOptions() - ) - supOpts ++ enableOpts.toSeq.flatten + override def mandatoryJavacOptions: T[Seq[String]] = T { + super.mandatoryJavacOptions() ++ errorProneJavacEnableOptions() } } diff --git a/contrib/errorprone/test/src/mill/contrib/errorprone/ErrorProneTests.scala b/contrib/errorprone/test/src/mill/contrib/errorprone/ErrorProneTests.scala index 617697d9a36..9621406281f 100644 --- a/contrib/errorprone/test/src/mill/contrib/errorprone/ErrorProneTests.scala +++ b/contrib/errorprone/test/src/mill/contrib/errorprone/ErrorProneTests.scala @@ -34,7 +34,7 @@ object ErrorProneTests extends TestSuite { } test("compileWarn") { val eval = UnitTester(errorProneCustom, testModuleSourcesPath, debugEnabled = true) - val Right(opts) = eval(errorProneCustom.javacOptions) + val Right(opts) = eval(errorProneCustom.mandatoryJavacOptions) assert(opts.value.exists(_.contains("-XepAllErrorsAsWarnings"))) val res = eval(errorProneCustom.compile) assert(res.isRight) diff --git a/contrib/scoverage/test/src/mill/contrib/scoverage/HelloWorldTests.scala b/contrib/scoverage/test/src/mill/contrib/scoverage/HelloWorldTests.scala index 87c0befa9ff..887a3b66bb4 100644 --- a/contrib/scoverage/test/src/mill/contrib/scoverage/HelloWorldTests.scala +++ b/contrib/scoverage/test/src/mill/contrib/scoverage/HelloWorldTests.scala @@ -55,7 +55,7 @@ trait HelloWorldTests extends utest.TestSuite { def scalaVersion = testScalaVersion def scoverageVersion = testScoverageVersion - object test extends SbtModuleTests with ScoverageTests with TestModule.ScalaTest { + object test extends SbtTests with ScoverageTests with TestModule.ScalaTest { override def ivyDeps = Agg(ivy"org.scalatest::scalatest:${testScalatestVersion}") } } diff --git a/contrib/testng/test/src/mill/testng/TestNGTests.scala b/contrib/testng/test/src/mill/testng/TestNGTests.scala index d9cd0694e01..2cab918689e 100644 --- a/contrib/testng/test/src/mill/testng/TestNGTests.scala +++ b/contrib/testng/test/src/mill/testng/TestNGTests.scala @@ -6,14 +6,13 @@ import mill.util.Util.millProjectModule import mill.scalalib._ import mill.testkit.UnitTester import mill.testkit.TestBaseModule -import utest.framework.TestPath import utest.{TestSuite, Tests, assert, _} object TestNGTests extends TestSuite { object demo extends TestBaseModule with JavaModule { - object test extends JavaModuleTests { + object test extends JavaTests { def testngClasspath = T { millProjectModule( "mill-contrib-testng", diff --git a/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala b/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala index 3a55c9dd21f..dd0292d20e2 100644 --- a/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala +++ b/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala @@ -68,7 +68,6 @@ object HelloJSWorldTests extends TestSuite { object inherited extends ScalaJSModule { val (scala, scalaJS) = matrix.head def scalacOptions = Seq("-deprecation") - def mandatoryScalacOptions = Seq("-mandatory") def scalaOrganization = "org.example" def scalaVersion = scala def scalaJSVersion = scalaJS @@ -292,9 +291,6 @@ object HelloJSWorldTests extends TestSuite { test("test-scalacOptions") { checkInheritedTargets(_.scalacOptions, Seq("-deprecation")) } - test("test-mandatoryScalacOptions") { - checkInheritedTargets(_.mandatoryScalacOptions, Seq("-mandatory")) - } test("test-scalaOrganization") { checkInheritedTargets(_.scalaOrganization, "org.example") } diff --git a/scalalib/src/mill/scalalib/CrossSbtModule.scala b/scalalib/src/mill/scalalib/CrossSbtModule.scala index 1f4f2a9bc4b..f1e61c7cc4f 100644 --- a/scalalib/src/mill/scalalib/CrossSbtModule.scala +++ b/scalalib/src/mill/scalalib/CrossSbtModule.scala @@ -4,6 +4,8 @@ import mill.api.PathRef import mill.T import mill.scalalib.{CrossModuleBase, SbtModule} +import scala.annotation.nowarn + trait CrossSbtModule extends SbtModule with CrossModuleBase { outer => override def sources: T[Seq[PathRef]] = T.sources { @@ -12,9 +14,10 @@ trait CrossSbtModule extends SbtModule with CrossModuleBase { outer => ) } + @nowarn type CrossSbtTests = CrossSbtModuleTests @deprecated("Use CrossSbtTests instead", since = "Mill 0.11.10") - trait CrossSbtModuleTests extends SbtModuleTests { + trait CrossSbtModuleTests extends SbtTests { override def millSourcePath = outer.millSourcePath override def sources = T.sources { super.sources() ++ scalaVersionDirectoryNames.map(s => @@ -22,5 +25,6 @@ trait CrossSbtModule extends SbtModule with CrossModuleBase { outer => ) } } + @deprecated("Use CrossTests instead", since = "Mill after 0.12.0-RC1") trait Tests extends CrossSbtModuleTests } diff --git a/scalalib/src/mill/scalalib/JavaModule.scala b/scalalib/src/mill/scalalib/JavaModule.scala index cf29ce5e64c..3171c6a04a1 100644 --- a/scalalib/src/mill/scalalib/JavaModule.scala +++ b/scalalib/src/mill/scalalib/JavaModule.scala @@ -35,7 +35,8 @@ trait JavaModule with BspModule with SemanticDbJavaModule { outer => - def zincWorker: ModuleRef[ZincWorkerModule] = super.zincWorker + override def zincWorker: ModuleRef[ZincWorkerModule] = super.zincWorker + @nowarn type JavaTests = JavaModuleTests @deprecated("Use JavaTests instead", since = "Mill 0.11.10") trait JavaModuleTests extends JavaModule with TestModule { @@ -160,6 +161,11 @@ trait JavaModule */ def javacOptions: T[Seq[String]] = T { Seq.empty[String] } + /** + * Additional options for the java compiler derived from other module settings. + */ + def mandatoryJavacOptions: T[Seq[String]] = T { Seq.empty[String] } + /** * The direct dependencies of this module. * This is meant to be overridden to add dependencies. @@ -422,7 +428,7 @@ trait JavaModule upstreamCompileOutput = upstreamCompileOutput(), sources = allSourceFiles().map(_.path), compileClasspath = compileClasspath().map(_.path), - javacOptions = javacOptions(), + javacOptions = javacOptions() ++ mandatoryJavacOptions(), reporter = T.reporter.apply(hashCode), reportCachedProblems = zincReportCachedProblems(), incrementalCompilation = zincIncrementalCompilation() diff --git a/scalalib/src/mill/scalalib/MavenModule.scala b/scalalib/src/mill/scalalib/MavenModule.scala index bb84f51eaa6..4851d1e9ffb 100644 --- a/scalalib/src/mill/scalalib/MavenModule.scala +++ b/scalalib/src/mill/scalalib/MavenModule.scala @@ -2,6 +2,8 @@ package mill.scalalib import mill.T +import scala.annotation.nowarn + /** * A [[JavaModule]] with a Maven compatible directory layout. * @@ -16,9 +18,10 @@ trait MavenModule extends JavaModule { outer => millSourcePath / "src/main/resources" } + @nowarn type MavenTests = MavenModuleTests @deprecated("Use JavaTests instead", since = "Mill 0.11.10") - trait MavenModuleTests extends JavaModuleTests { + trait MavenModuleTests extends JavaTests { 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 8960ab9721b..6ff37c5a636 100644 --- a/scalalib/src/mill/scalalib/SbtModule.scala +++ b/scalalib/src/mill/scalalib/SbtModule.scala @@ -2,6 +2,8 @@ package mill.scalalib import mill.T +import scala.annotation.nowarn + /** * A [[ScalaModule]] with sbt compatible directory layout. */ @@ -12,6 +14,7 @@ trait SbtModule extends ScalaModule with MavenModule { millSourcePath / "src/main/java" ) + @nowarn type SbtTests = SbtModuleTests @deprecated("Use SbtTests instead", since = "Mill 0.11.10") trait SbtModuleTests extends ScalaTests with MavenTests { diff --git a/scalalib/src/mill/scalalib/ScalaModule.scala b/scalalib/src/mill/scalalib/ScalaModule.scala index ac78703feb1..d5ae1354465 100644 --- a/scalalib/src/mill/scalalib/ScalaModule.scala +++ b/scalalib/src/mill/scalalib/ScalaModule.scala @@ -28,13 +28,13 @@ trait ScalaModule extends JavaModule with TestModule.ScalaModuleBase { outer => @deprecated("use ScalaTests", "0.11.0") type ScalaModuleTests = ScalaTests - trait ScalaTests extends JavaModuleTests with ScalaModule { + trait ScalaTests extends JavaTests with ScalaModule { override def scalaOrganization: Target[String] = outer.scalaOrganization() override def scalaVersion: Target[String] = outer.scalaVersion() override def scalacPluginIvyDeps: Target[Agg[Dep]] = outer.scalacPluginIvyDeps() override def scalacPluginClasspath: Target[Agg[PathRef]] = outer.scalacPluginClasspath() override def scalacOptions: Target[Seq[String]] = outer.scalacOptions() - override def mandatoryScalacOptions: Target[Seq[String]] = outer.mandatoryScalacOptions() + override def mandatoryScalacOptions: Target[Seq[String]] = T { super.mandatoryScalacOptions() } } /** @@ -279,7 +279,7 @@ trait ScalaModule extends JavaModule with TestModule.ScalaModuleBase { outer => upstreamCompileOutput = upstreamCompileOutput(), sources = allSourceFiles().map(_.path), compileClasspath = compileClasspath().map(_.path), - javacOptions = javacOptions(), + javacOptions = javacOptions() ++ mandatoryJavacOptions(), scalaVersion = sv, scalaOrganization = scalaOrganization(), scalacOptions = allScalacOptions(), diff --git a/scalalib/src/mill/scalalib/SemanticDbJavaModule.scala b/scalalib/src/mill/scalalib/SemanticDbJavaModule.scala index 3c810af0985..7a15dd89b07 100644 --- a/scalalib/src/mill/scalalib/SemanticDbJavaModule.scala +++ b/scalalib/src/mill/scalalib/SemanticDbJavaModule.scala @@ -20,6 +20,7 @@ trait SemanticDbJavaModule extends CoursierModule { def compile: T[mill.scalalib.api.CompilationResult] def bspBuildTarget: BspBuildTarget def javacOptions: T[Seq[String]] + def mandatoryJavacOptions: T[Seq[String]] def compileClasspath: T[Agg[PathRef]] def semanticDbVersion: T[String] = T.input { @@ -98,7 +99,10 @@ trait SemanticDbJavaModule extends CoursierModule { } def semanticDbData: T[PathRef] = T.persistent { - val javacOpts = SemanticDbJavaModule.javacOptionsTask(javacOptions(), semanticDbJavaVersion()) + val javacOpts = SemanticDbJavaModule.javacOptionsTask( + javacOptions() ++ mandatoryJavacOptions(), + semanticDbJavaVersion() + ) // we currently assume, we don't do incremental java compilation os.remove.all(T.dest / "classes") diff --git a/scalalib/test/src/mill/scalalib/HelloJavaTests.scala b/scalalib/test/src/mill/scalalib/HelloJavaTests.scala index 4d958670d2e..fd95ea632f1 100644 --- a/scalalib/test/src/mill/scalalib/HelloJavaTests.scala +++ b/scalalib/test/src/mill/scalalib/HelloJavaTests.scala @@ -12,13 +12,13 @@ object HelloJavaTests extends TestSuite { object HelloJava extends TestBaseModule { object core extends JavaModule { override def docJarUseArgsFile = false - object test extends JavaModuleTests with TestModule.Junit4 + object test extends JavaTests with TestModule.Junit4 } object app extends JavaModule { override def docJarUseArgsFile = true override def moduleDeps = Seq(core) - object test extends JavaModuleTests with TestModule.Junit4 - object testJunit5 extends JavaModuleTests with TestModule.Junit5 { + object test extends JavaTests with TestModule.Junit4 + object testJunit5 extends JavaTests with TestModule.Junit5 { override def ivyDeps: T[Agg[Dep]] = T { super.ivyDeps() ++ Agg(ivy"org.junit.jupiter:junit-jupiter-params:5.7.0") }