harrah/xsbt — Issue #387: Sbt does not remove empty output directories when appropriate
Author: Blaisorblade
Created: 2012-03-05 10:03:27+00:00
State: open

I renamed a package from `a.pkgName` to `pkgName`; other files in package `a` contained `import pkgName.Foo`, which is still correct, but now does not compile any more, with an error similar to:

```
[error] /app/home/pgiarrusso/LinqOnSteroids/src/test/scala/a/tests/Bar.scala:40: object Foo is not a member of package a.pkgName
[error] import pkgName.Foo
```

Removing the directory `target/scala-$ver/classes/a/pkgName` fixes the problem, and `sbt` should do that automatically: that directory suggests `scalac` that the package `a.pkgName` still exists, so that `import pkgName.Foo` resolves to `import a.pkgName.Foo` rather than `import pkgName.Foo`, which is now the correct interpretation.

What I suggest, algorithmically, is that if all class files in a directory depend on sources which are going to be recompiled, the directory should be removed, since scalac is going to recreate it anyway _if needed_.