mirror of https://github.com/sbt/sbt.git
Merge pull request #4099 from eatkins/redundant
Handle managedSources writing into unmanaged source directories
This commit is contained in:
commit
7e8e18b9fa
|
|
@ -330,7 +330,18 @@ object Defaults extends BuildCommon {
|
|||
val baseDir = baseDirectory.value
|
||||
val bases = unmanagedSourceDirectories.value
|
||||
val include = (includeFilter in unmanagedSources).value
|
||||
val exclude = (excludeFilter in unmanagedSources).value
|
||||
val exclude = (excludeFilter in unmanagedSources).value match {
|
||||
case e =>
|
||||
(managedSources in ThisScope).value match {
|
||||
case l if l.nonEmpty =>
|
||||
e || new FileFilter {
|
||||
private val files = l.toSet
|
||||
override def accept(pathname: File): Boolean = files.contains(pathname)
|
||||
override def toString = s"ManagedSourcesFilter($files)"
|
||||
}
|
||||
case _ => e
|
||||
}
|
||||
}
|
||||
val baseSources =
|
||||
if (sourcesInBase.value) Seq(new Source(baseDir, include, exclude, recursive = false))
|
||||
else Nil
|
||||
|
|
@ -342,7 +353,7 @@ object Defaults extends BuildCommon {
|
|||
sourceDirectories := Classpaths
|
||||
.concatSettings(unmanagedSourceDirectories, managedSourceDirectories)
|
||||
.value,
|
||||
sources := Classpaths.concat(unmanagedSources, managedSources).value
|
||||
sources := Classpaths.concatDistinct(unmanagedSources, managedSources).value
|
||||
)
|
||||
lazy val resourceConfigPaths = Seq(
|
||||
resourceDirectory := sourceDirectory.value / "resources",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
import java.nio.file.Files
|
||||
|
||||
lazy val watchLoopTest = taskKey[Unit]("Check that managed sources are filtered")
|
||||
|
||||
sourceGenerators in Compile += Def.task {
|
||||
val path = baseDirectory.value.toPath.resolve("src/main/scala/Foo.scala")
|
||||
Files.write(path, "object Foo".getBytes).toFile :: Nil
|
||||
}
|
||||
|
||||
watchLoopTest := {
|
||||
val watched = watchSources.value
|
||||
val managedSource = (managedSources in Compile).value.head
|
||||
assert(!SourceWrapper.accept(watched, managedSource))
|
||||
assert((sources in Compile).value.foldLeft((true, Set.empty[File])) {
|
||||
case ((res, set), f) => (res && !set.contains(f), set + f)
|
||||
}._1)
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package sbt
|
||||
|
||||
object SourceWrapper {
|
||||
def accept(sources: Seq[sbt.internal.io.Source], file: File): Boolean =
|
||||
sources.exists(_.accept(file.toPath))
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
object Bar
|
||||
|
|
@ -0,0 +1 @@
|
|||
object Foo
|
||||
|
|
@ -0,0 +1 @@
|
|||
> watchLoopTest
|
||||
Loading…
Reference in New Issue