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 24, 2017
1 parent 9e85c08 commit 78c5ee9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 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][]
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object Dependencies {
val baseScalaVersion = scala212

// sbt modules
private val ioVersion = "1.0.1"
private val ioVersion = "1.0.2"
private val utilVersion = "1.0.1"
private val lmVersion = "1.0.2"
private val zincVersion = "1.0.1"
Expand Down

0 comments on commit 78c5ee9

Please sign in to comment.