Reputation: 125
I have a root project containing 3 subprojects plus sbt config files and nothing else. 2 main subprojects are called server
and backend
, the other is called common
and is dependency of both main projects. server
is PlayFramework project. backed
project is configured to generate assembly jar into resources directory of server
.
The jar is generated correctly and server is able to see it, but I don't know how to run assembly
task from backend
when server
is compiled(i.e. I want the server to depend on assembly of backend.jar)
/* [...] */
lazy val commonSettings = Seq(
version := "0.1",
organization := "org.example",
scalaVersion := "2.11.7"
)
lazy val server = (project in file("server")).enablePlugins(PlayJava).settings(commonSettings: _*).settings(
name := """example""",
libraryDependencies ++= Seq(
/* [...] */
),
/* [...] */
unmanagedResourceDirectories in Compile += { baseDirectory.value / "resources" }
).dependsOn(common)
lazy val backend = (project in file("backend")).settings(commonSettings: _*).settings(
assemblyJarName in assembly := "backend.jar",
assemblyOutputPath in assembly := server.base / "resources/backend.jar",
libraryDependencies := Seq(
)
).dependsOn(common)
lazy val common = (project in file("common")).settings(commonSettings: _*)
onLoad in Global := (Command.process("project server", _: State)) compose (onLoad in Global).value
Upvotes: 3
Views: 370
Reputation: 125
Thanks to comment by @pfn I got it working. One thing I needed to do was to insert this line in server subproject settings and change server
to Compile
, so it is now:
(compile in Compile) <<= (compile in Compile) dependsOn (assembly in backend)
Upvotes: 2