How to prevent generation of Java folders in a SBT project using sbteclipse

If you're using sbteclipse in a SBT project and there are no Java files in your project, you don't need of both src/main/java and src/test/java folders. But every time you run "sbt eclipse", the Java folders are regenerated.

There is a way to prevent those directories from being generated. To do that you need to avoid the Java source directories to be created, simply redefine unmanagedSourceDirectories by adding these two settings:

1 unmanagedSourceDirectories in Compile <<= (scalaSource in Compile)(Seq(_)),
2 unmanagedSourceDirectories in Test <<= (scalaSource in Test)(Seq(_))

And it's an example of a build.scala file, see how you can add those settings:

 1 object AppBuilder extends Build {
 2 
 3   val appSettings = Seq(
 4     name := "apptest",
 5     organization := "com.rlazoti",
 6     version := "0.0.1-SNAPSHOT",
 7     scalaVersion := "2.10.2",
 8     unmanagedSourceDirectories in Compile <<= (scalaSource in Compile)(Seq(_)),
 9     unmanagedSourceDirectories in Test <<= (scalaSource in Test)(Seq(_))
10   )
11 
12   lazy val app = Project("apptest", file("."))
13     .settings(appSettings : _*)
14 
15 }

comments powered by Disqus