From bb0fd5c84c274a5464af363dc8882796578b84cd Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Sat, 21 Sep 2019 10:39:54 -0700 Subject: [PATCH] Fix checkbuild sources for projects with meta-meta-build If a project had a meta-meta build (project/project), the build sources in the project directory were ignored. This was because the projectGlobs method did not correctly handle recursion. It inadvertently discarded the accumulator globs and only returned the most recently generated globs. This commit fixes that and adds a regression test to the nio/reload scripted test. --- main/src/main/scala/sbt/internal/nio/CheckBuildSources.scala | 4 ++-- sbt/src/sbt-test/nio/reload/test | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/main/src/main/scala/sbt/internal/nio/CheckBuildSources.scala b/main/src/main/scala/sbt/internal/nio/CheckBuildSources.scala index 782975b75..a2e54fb24 100644 --- a/main/src/main/scala/sbt/internal/nio/CheckBuildSources.scala +++ b/main/src/main/scala/sbt/internal/nio/CheckBuildSources.scala @@ -67,14 +67,14 @@ private[sbt] object CheckBuildSources { @tailrec def projectGlobs(projectDir: File, globs: Seq[Glob]): Seq[Glob] = { val glob = projectDir.toGlob - val base = Seq( + val updatedGlobs = globs ++ Seq( glob / "*.{sbt,scala,java}", // We only want to recursively look in source because otherwise we have to search // the project target directories which is expensive. glob / "src" / ** / "*.{scala,java}" ) val nextLevel = projectDir / "project" - if (nextLevel.exists) projectGlobs(nextLevel, base) else base + if (nextLevel.exists) projectGlobs(nextLevel, updatedGlobs) else updatedGlobs } projectGlobs(projectDir, baseDir.toGlob / "*.sbt" :: Nil) } else Nil diff --git a/sbt/src/sbt-test/nio/reload/test b/sbt/src/sbt-test/nio/reload/test index 26ef1a9ff..1d59941b2 100644 --- a/sbt/src/sbt-test/nio/reload/test +++ b/sbt/src/sbt-test/nio/reload/test @@ -29,3 +29,7 @@ $ copy-file changes/sub.sbt sub/build.sbt $ copy-file changes/ScalafmtVersion.scala project/project/ScalafmtVersion.scala > scalafmt + +$ delete project/plugins.sbt + +-> scalafmt