7

What is the best way to generate separate jar files using sbt for multiple main classes under the same source tree?

The project directory looks something like this:

project_root/
        src/main/scala/
                     A/*.scala files for main class A
                     B/*.scala files for main class B
                 resources/
            test/scala/
                     A/
                     B/
        lib/
        project/Build.scala
        build.sbt   

Notice that both A and B have the same base. Concrete examples of Build.scala file would be helpful.

Jens Björnhager
  • 5,632
  • 3
  • 27
  • 47
deepkimo
  • 3,187
  • 3
  • 23
  • 21

1 Answers1

1

You should have a look at Getting Started Multi Project. I made a simple example below:

import sbt._

object MyBuild extends Build {

  lazy val projA = Project("projA", file("a")) 

  lazy val projB = Project("projB", file("b"))
}
Emil L
  • 20,219
  • 3
  • 44
  • 65
  • 1
    This wouldn't work for the case I am describing, since both projects have the same base. – deepkimo Mar 03 '13 at 21:42
  • You could create a third project which contains the common clsasses and use `dependsOn` as described in the link under "Classpath dependencies". Or you could try to make two projects with the same base path and then exclude some classes from the build in each projects (I haven't tried this so not sure if it would work). Here is an answere showing how to exclude java classes from the build so you could probably adapt it to your needs. http://stackoverflow.com/a/8896784/355499 – Emil L Mar 04 '13 at 07:40