3
votes

I observed SBT compiles all source files everytime when I issue the "compile" task, regardless of time stamps since the last compile. The following is my build.sbt file:

name := "HelloSbt"

scalaVersion := "2.8.2"

unmanagedSourceDirectories in Compile := List(file("src"))

The following is my project structure (ignored project and target directories):

./src
./src/Hello1.scala
./src/a
./src/a/Hello2.scala
./build.sbt

The two source files are just empty object definitions for test purpose.

When I type in "sbt compile", I got the following information:

[info] Compiling 2 Scala sources to...

and I can find newly compiled class files in target directory.

Without modifying any source file, after a minute, typing "sbt compile" again I got the same info and class files, except the time stamp of class files are up to date. I was expecting the second compile would not find any modified source file and no compilation should happen.

I did the test in both Windows 7 and Debian. During the test, I didn't have any editor open. Can some one give some hint about how to setup a customized src directory while still be able to only compile modified files since last build?

Thanks

1
Not in the answer, but I'd open an issue about it. I think at least a warning is warranted.Daniel C. Sobral

1 Answers

1
votes

That's because you are using a relative path as if it were an absolute path. I'm surprised it even produces a result, but, anyway, you should write it like this:

unmanagedSourceDirectories in Compile <<= baseDirectory(base => List(base / "src"))