mirror of https://github.com/sbt/sbt.git
Generate an error when the incremental compiler is given relative source files. Fixes #923.
Review by @gkossakowski
This commit is contained in:
parent
45d81a03a1
commit
2f683ef81d
|
|
@ -226,6 +226,7 @@ object Incremental
|
|||
val byProduct = changes.removedProducts.flatMap(previous.produced)
|
||||
val byBinaryDep = changes.binaryDeps.flatMap(previous.usesBinary)
|
||||
val byExtSrcDep = invalidateByExternal(previous, changes.external.modified, log) //changes.external.modified.flatMap(previous.usesExternal) // ++ scopeInvalidations
|
||||
checkAbsolute(srcChanges.added.toList)
|
||||
log.debug(
|
||||
"\nInitial source changes: \n\tremoved:" + srcChanges.removed + "\n\tadded: " + srcChanges.added + "\n\tmodified: " + srcChanges.changed +
|
||||
"\nRemoved products: " + changes.removedProducts +
|
||||
|
|
@ -240,6 +241,19 @@ object Incremental
|
|||
|
||||
srcDirect ++ byProduct ++ byBinaryDep ++ byExtSrcDep
|
||||
}
|
||||
private[this] def checkAbsolute(addedSources: List[File]): Unit =
|
||||
if(addedSources.nonEmpty) {
|
||||
addedSources.filterNot(_.isAbsolute) match {
|
||||
case first :: more =>
|
||||
val fileStrings = more match {
|
||||
case Nil => first.toString
|
||||
case x :: Nil => s"$first and $x"
|
||||
case _ => s"$first and ${more.size} others"
|
||||
}
|
||||
sys.error(s"The incremental compiler requires absolute sources, but some were relative: $fileStrings")
|
||||
case Nil =>
|
||||
}
|
||||
}
|
||||
|
||||
/** Sources invalidated by `external` sources in other projects according to the previous `relations`. */
|
||||
def invalidateByExternal(relations: Relations, external: Set[String], log: Logger): Set[File] =
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
scalaSource in Compile := baseDirectory.value / "src"
|
||||
|
|
@ -0,0 +1 @@
|
|||
scalaSource in Compile := file("src")
|
||||
|
|
@ -0,0 +1 @@
|
|||
object A
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
$ copy-file changes/relative.sbt build.sbt
|
||||
-> compile
|
||||
$ copy-file changes/absolute.sbt build.sbt
|
||||
> compile
|
||||
Loading…
Reference in New Issue