diff --git a/contrib/errorprone/readme.adoc b/contrib/errorprone/readme.adoc index af67982b5d3..159b045051a 100644 --- a/contrib/errorprone/readme.adoc +++ b/contrib/errorprone/readme.adoc @@ -5,7 +5,7 @@ https://errorprone.info/index[Error Prone] augments the Java compiler's type che You just need to mix the `ErrorProneModule` into your `JavaModule` and it will automatically run with every compilation. -.`build.mill.sc`: Enable `ErrorProne` in a module +.`build.mill.scala`: Enable `ErrorProne` in a module [source,scala] ---- package build diff --git a/example/depth/large/13-helper-files-mill-sc/build.mill.sc b/example/depth/large/13-helper-files-mill-scala/build.mill.scala similarity index 90% rename from example/depth/large/13-helper-files-mill-sc/build.mill.sc rename to example/depth/large/13-helper-files-mill-scala/build.mill.scala index 7a757d7b0ba..0a0b47444fa 100644 --- a/example/depth/large/13-helper-files-mill-sc/build.mill.sc +++ b/example/depth/large/13-helper-files-mill-scala/build.mill.scala @@ -8,9 +8,9 @@ object `package` extends RootModule with MyModule{ "MY_PROJECT_VERSION" -> versions.myProjectVersion, ) } -///** See Also: util.mill.sc */ -///** See Also: foo/package.mill.sc */ -///** See Also: foo/versions.mill.sc */ +///** 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 diff --git a/example/depth/large/13-helper-files-mill-sc/foo/package.mill.sc b/example/depth/large/13-helper-files-mill-scala/foo/package.mill.scala similarity index 100% rename from example/depth/large/13-helper-files-mill-sc/foo/package.mill.sc rename to example/depth/large/13-helper-files-mill-scala/foo/package.mill.scala diff --git a/example/depth/large/13-helper-files-mill-sc/foo/src/Foo.scala b/example/depth/large/13-helper-files-mill-scala/foo/src/Foo.scala similarity index 100% rename from example/depth/large/13-helper-files-mill-sc/foo/src/Foo.scala rename to example/depth/large/13-helper-files-mill-scala/foo/src/Foo.scala diff --git a/example/depth/large/13-helper-files-mill-sc/foo/versions.mill.sc b/example/depth/large/13-helper-files-mill-scala/foo/versions.mill.scala similarity index 100% rename from example/depth/large/13-helper-files-mill-sc/foo/versions.mill.sc rename to example/depth/large/13-helper-files-mill-scala/foo/versions.mill.scala diff --git a/example/depth/large/13-helper-files-mill-sc/src/Main.scala b/example/depth/large/13-helper-files-mill-scala/src/Main.scala similarity index 100% rename from example/depth/large/13-helper-files-mill-sc/src/Main.scala rename to example/depth/large/13-helper-files-mill-scala/src/Main.scala diff --git a/example/depth/large/13-helper-files-mill-sc/util.mill.sc b/example/depth/large/13-helper-files-mill-scala/util.mill.scala similarity index 100% rename from example/depth/large/13-helper-files-mill-sc/util.mill.sc rename to example/depth/large/13-helper-files-mill-scala/util.mill.scala diff --git a/main/client/src/mill/main/client/CodeGenConstants.java b/main/client/src/mill/main/client/CodeGenConstants.java index 71136e2d1dd..5a5f1b55733 100644 --- a/main/client/src/mill/main/client/CodeGenConstants.java +++ b/main/client/src/mill/main/client/CodeGenConstants.java @@ -21,17 +21,17 @@ public class CodeGenConstants { /** * The name of the root build file */ - final public static String[] rootBuildFileNames = {"build.mill", "build.mill.sc", "build.sc"}; + final public static String[] rootBuildFileNames = {"build.mill", "build.mill.scala", "build.sc"}; /** * The name of any sub-folder build files */ - final public static String[] nestedBuildFileNames = {"package.mill", "package.mill.sc", "package.sc"}; + final public static String[] nestedBuildFileNames = {"package.mill", "package.mill.scala", "package.sc"}; /** * The extensions used by build files */ - final public static String[] buildFileExtensions = {"mill", "mill.sc", "sc"}; + final public static String[] buildFileExtensions = {"mill", "mill.scala", "sc"}; /** * The user-facing name for the root of the module tree. diff --git a/mill-build/src/ExampleParser.scala b/mill-build/src/ExampleParser.scala index 39988ee2a86..de7b82c7cd8 100644 --- a/mill-build/src/ExampleParser.scala +++ b/mill-build/src/ExampleParser.scala @@ -6,9 +6,15 @@ object ExampleParser { val states = collection.mutable.Buffer("scala") val chunks = collection.mutable.Buffer(collection.mutable.Buffer.empty[String]) - val rootBuildFileNames = Seq("build.sc", "build.mill", "build.mill.sc") - val buildFile = rootBuildFileNames.map(testRepoRoot / _).find(os.exists) - for (line <- os.read.lines(buildFile.get)) { + val rootBuildFileNames = Seq("build.sc", "build.mill", "build.mill.scala") + val buildFile = rootBuildFileNames.map(testRepoRoot / _) + .find(os.exists) + .getOrElse( + sys.error( + s"No build file named ${rootBuildFileNames.mkString("/")} found in $testRepoRoot" + ) + ) + for (line <- os.read.lines(buildFile)) { val (newState, restOpt) = line match { case s"/** Usage" => ("example", None) case s"/** See Also: $path */" => diff --git a/runner/src/mill/runner/FileImportGraph.scala b/runner/src/mill/runner/FileImportGraph.scala index fae30b35174..b589c2bfabf 100644 --- a/runner/src/mill/runner/FileImportGraph.scala +++ b/runner/src/mill/runner/FileImportGraph.scala @@ -66,7 +66,7 @@ object FileImportGraph { val expectedImportSegments = expectedImportSegments0.map(backtickWrap).mkString(".") if ( // Legacy `.sc` files have their package build be optional - (s.last.endsWith(".mill") || s.last.endsWith(".mill.sc")) && + (s.last.endsWith(".mill") || s.last.endsWith(".mill.scala")) && expectedImportSegments != importSegments && // Root build.mill file has its `package build` be optional !(importSegments == "" && rootBuildFileNames.contains(s.last)) @@ -136,7 +136,7 @@ object FileImportGraph { case ImportTree(Seq(("$file", end0), rest @ _*), mapping, start, end) => // Only recursively explore imports from legacy `.sc` files, as new `.mill` files // do file discovery via scanning folders containing `package.mill` files - if (s.last.endsWith(".sc") && !s.last.endsWith(".mill.sc")) { + if (s.last.endsWith(".sc") && !s.last.endsWith(".mill.scala")) { val nextPaths = mapping.map { case (lhs, rhs) => nextPathFor(s, rest.map(_._1) :+ lhs) } @@ -161,10 +161,18 @@ object FileImportGraph { } val rootBuildFiles = rootBuildFileNames - .find(rootBuildFileName => os.exists(projectRoot / rootBuildFileName)) - - val useDummy = rootBuildFiles.isEmpty - val foundRootBuildFileName: String = rootBuildFiles.getOrElse(rootBuildFileNames.head) + .filter(rootBuildFileName => os.exists(projectRoot / rootBuildFileName)) + + val (useDummy, foundRootBuildFileName) = rootBuildFiles.toSeq match { + case Nil => (true, rootBuildFileNames.head) + case Seq(single) => (false, single) + case multiple => + System.err.println( + "Multiple root build files found: " + multiple.mkString(",") + + ", picking " + multiple.head + ) + (false, multiple.head) + } val buildFileExtension = buildFileExtensions.find(ex => foundRootBuildFileName.endsWith(s".$ex")).get