From ec62fee2670389b60d3d9f7e09dfc04311de7318 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Wed, 11 Oct 2017 18:45:55 +0100 Subject: [PATCH] Track sources in base directory non-recursively Using a recursive Source meant that ~ looked into target. If you have any source generators and use ~ with anything the invokes them, like ~compile, that means that the act of generating sources triggers ~ to re-execute compile (perhaps only on macOS where the NIO WatchService just polls, after an initial delay). Requires sbt/io#78 Fixes #3501 --- main/src/main/scala/sbt/Defaults.scala | 8 +++++--- notes/1.0.3/watch2.md | 12 ++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 notes/1.0.3/watch2.md diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 6664c493566..6405a288698 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -315,11 +315,13 @@ object Defaults extends BuildCommon { excludeFilter in unmanagedSources).value, watchSources in ConfigGlobal ++= { val baseDir = baseDirectory.value - val bases = unmanagedSourceDirectories.value ++ (if (sourcesInBase.value) Seq(baseDir) - else Seq.empty) + val bases = unmanagedSourceDirectories.value val include = (includeFilter in unmanagedSources).value val exclude = (excludeFilter in unmanagedSources).value - bases.map(b => new Source(b, include, exclude)) + val baseSources = + if (sourcesInBase.value) Seq(new Source(baseDir, include, exclude, recursive = false)) + else Nil + bases.map(b => new Source(b, include, exclude)) ++ baseSources }, managedSourceDirectories := Seq(sourceManaged.value), managedSources := generate(sourceGenerators).value, diff --git a/notes/1.0.3/watch2.md b/notes/1.0.3/watch2.md new file mode 100644 index 00000000000..69b30cede14 --- /dev/null +++ b/notes/1.0.3/watch2.md @@ -0,0 +1,12 @@ +[@dwijnand]: https://github.com/dwijnand + +[#3501]: https://github.com/sbt/sbt/issues/3501 +[#3634]: https://github.com/sbt/sbt/pull/3634 + +### Fixes with compatibility implications + +### Improvements + +### Bug fixes + +- Fixes `~` to recompile on loop (when a source generator or sbt-buildinfo is present). [#3501][]/[#3634][] by [@dwijnand][]