Skip to content

Commit

Permalink
Track sources in base directory non-recursively
Browse files Browse the repository at this point in the history
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 sbt#3501
  • Loading branch information
dwijnand committed Oct 13, 2017
1 parent 85af599 commit ec62fee
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main/src/main/scala/sbt/Defaults.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions notes/1.0.3/watch2.md
Original file line number Diff line number Diff line change
@@ -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][]

0 comments on commit ec62fee

Please sign in to comment.