Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separate jars for different main classes under same src

Tags:

jar

scala

build

sbt

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.

like image 907
deepkimo Avatar asked Mar 02 '13 01:03

deepkimo


People also ask

Can a jar have multiple main classes?

Jar files can contain only one Main-Class attribute in the manifest, which means a jar can contain only one mainClassName.


1 Answers

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"))
}
like image 176
Emil H Avatar answered Oct 19 '22 15:10

Emil H