Update
If I got you correct now, you want to be able to call the source generators seperately. For that you can simply define a custom task like this somewhere in your /build.sbt or /project/Project.scala file:
val generateSources = taskKey[List[File]]("generate sources")
generateSources <<=
(sourceGenerators in Compile) { _.join.map(_.flatten.toList) }
you can then call the generator manually from the sbt console like this:
> generateSources
[success] Total time: 0 s, completed 07.04.2014 13:42:41
Side Note:
I would however reccomend to setup your IDE to generate the sources if the only thing you need them for is to get IDE support.
Old answer for future reference
You don't need to do anything special to use a generated class or object from a non-generated class or object.
In your /build.sbt or /project/Project.scala file you define the source generator:
sourceGenerators in Compile <+= sourceManaged in Compile map { dir =>
val file = dir / "A.scala"
IO.write(file, "class A(val name: String)")
Seq(file)
}
Then you write some code which creates an instance of class A in/src/main/scala/B.scala:
object B extends App {
val a = new A("It works")
println(a.name)
}
If you compile this code from sbt, it will consider both generated and non-generated code at compilation:
> run
[info] Compiling 2 scala sources to <...>
[info] Running B
It works
[success] Total time: 0 s, completed 07.04.2014 13:15:47
sbt compile. I have now added a Generators.scala file in the project folder in my application. Then I have added a new task (makeGamedata) in my build.sbt which uses the Generators class to generate source code. So my development cycle is now:sbt makeGamedata> wrote code onsrc/main/scalathat is using the generated source >sbt compileto compile everything. This works good. Now I need to figure out how to unit test code in the project folder .. - reikjesbt generateto generate source code insrc_managed> develop code that uses these source insrc/main/scala> compile everything. - reikje