Open sslavic opened 10 years ago
I think the example in https://github.com/xerial/sbt-pack/blob/develop/src/sbt-test/sbt-pack/multi-module/ is exactly what you mentioned.
And its project settings are here: https://github.com/xerial/sbt-pack/blob/develop/src/sbt-test/sbt-pack/multi-module/project/Build.scala
Please append packSettings
only to the root project.
Does that work for your project structure?
I've seen the multi-module example before opening this ticket. Unfortunatelly that example is fundamentally broken, it mixes up dependencies from both modules into one package. That happens even if root aggregates module1 and module2, and depends only on module1 and defines packMain only for m1 - package will include module2 and its dependencies.
I've thought pack/pack-archive command will be available at root only if packSettings is added to root also. But it turns out if at least one submodule has packSettings, pack/pack-archive can be run from root project which aggregates that submodule (even when root project itself doesn't have packSettings applied), and build will correctly produce package only for submodule with packSettings, building along any submodule interdependencies as in example
import sbt._
import sbt.Keys._
import xerial.sbt.Pack._
object Build extends sbt.Build {
val commonSettings = Defaults.defaultSettings ++ Seq(
scalaVersion := "2.10.3",
version := "0.1",
crossPaths := false
)
lazy val root = Project(
id = "multi-module",
base = file("."),
settings = commonSettings,
aggregate = Seq(
module1,
module2
)
)
lazy val module1 = Project(
id = "module1",
base = file("module1"),
settings = commonSettings ++ packSettings ++ Seq(
packMain := Map("m1" -> "sample.Module1"),
libraryDependencies += "org.xerial" % "xerial-core" % "3.2.1"
)
).dependsOn(module2)
lazy val module2 = Project(
id = "module2",
base = file("module2"),
settings = commonSettings ++ Seq(
libraryDependencies += "org.xerial.snappy" % "snappy-java" % "1.1.0"
)
)
}
AFAIAC issue can be closed.
@sslavic
Thanks for the detailed project example. I misunderstood the difference of aggregate
and dependsOn
.
Aggregated projects never involve classpath dependencies but current sbt-pack implementation does not distinguish them.
This should be fixed in the next version (0.6.x),
Thanks
Please provide an example multi-module project where only one module produces a executable package with dependencies, while either pack command is runnable from root project, or better pack of the sole packageable module is done as part of regular package task.