SBT build skips some subprojects

I have a project with several sbt modules that is configured to build sbt. In this project, I want to skip the live flag generation for subprojects that are not intended to be executed in order to speed up the build. But I'm not sure how to do this.

+10
sbt
source share
2 answers

Just do not enable build settings in submodules that do not require this.

For example, using sbt 0.13.5 and sbt-assembly 0.11.2, here is a multi-module project. If you run assembly at the root, just the "app" project will be turned 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))) } 
+1
source share

If you use the build.sbt file, you can disable the build module for the 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( ... ) 

(The answer was found thanks to the comment by @tobym in another answer.)

0
source share

All Articles