开发者

How do I build multiple jar files using scala sbt

开发者 https://www.devze.com 2023-03-13 18:27 出处:网络
In my project I have the following structure: src/ plugins/ \\__ mpc __ oper I compile all of the scala files in src into a single jar (the main program), then each subdirectory in plugins c

In my project I have the following structure:

src/

plugins/

\__ mpc

|__ oper

I compile all of the scala files in src into a single jar (the main program), then each subdirectory in plugins contains scala files that should build a plugin jar to be loaded by the main program (so one jar for plugins/mpc and another for plugins/oper).

In the root I have a build.sbt:

name := "mrtoms"

organization := "chilon"

version := "0.1"

libraryDependencies ++= Seq("commons-httpclient" % "commons-ht开发者_JS百科tpclient" % "3.1")

crossPaths := false

scalaHome := Some(file("/usr/share/scala"))

target := file("project/target")

scalaSource in Compile <<= baseDirectory(_ / "src")

mainClass := Some("org.chilon.mrtoms.MrToms")

That builds my main jar file from the files in src just fine.. how do I add jars for the sources file in each plugin directory?


Seems that you need full configuration (at the moment you are using basic one):

https://github.com/harrah/xsbt/wiki/Full-Configuration

In your case, root project is your main jar. Each plugin should then have it's own project, that root project aggregates. Full configuration can be something like this:

import sbt._

object MyBuild extends Build {
    lazy val root = Project("root", file(".")) aggregate (mpc, oper) 
    lazy val mpc  = Project("mpc", file("plugins/mpc")) dependsOn(pluginApi)
    lazy val oper = Project("sub2", file("plugins/oper")) dependsOn(pluginApi)
    lazy val pluginApi = Project("pluginApi", file("plugins/api"))
}
0

精彩评论

暂无评论...
验证码 换一张
取 消