I have an sbt multi module project which is configured for sbt assembly. In this project i want to skip the fat jar generation for sub projects that are not intended to be executable in order to speed the build up. But I'm not sure how this is done.
If you use a build.sbt file you can disable the assembly plugin for a module as follows:
lazy val module = (project in file("module"))
.disablePlugins(sbtassembly.AssemblyPlugin)
.settings(
...
)
This also works for the root module:
lazy val `project-name` = (project in file("."))
.disablePlugins(sbtassembly.AssemblyPlugin)
.aggregate(`module-1`, `module-2`)
.settings(
...
)
(Answer found thanks to @tobym 's comment in the other answer.)
Just don't include the assembly settings in the submodules that don't require it.
For example, using sbt 0.13.5 and sbt-assembly 0.11.2, here is a multimodule project. If you run assembly
in root, just the "app" project will be made into a fat jar.
project/Build.scala
import sbt._
import Keys._
import sbtassembly.Plugin.assemblySettings
object MyApp extends Build {
lazy val root = Project("root", file(".")).aggregate(common, app)
lazy val common = Project("common", file("common"))
lazy val app = Project("app", file("app")).settings(assemblySettings: _*).dependsOn(common)
}
common/src/main/scala/com/example/common/Hello.scala
package com.example.common
object Hello {
def hello(name: String): String = s"Hello, $name"
}
app/src/main/scala/com/example/hello/App.scala
package com.example.hello
import com.example.common.Hello._
object Main extends App {
println(hello(args(0)))
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With