I have an sbt project with many subprojects and external library dependencies. build.sbt as follows:
val extlib1 = "xy.xxx" % "lib1" % "1.0+" val extlib2 = "xy.yyy" % "lib2" % "1.0+" val extlib3 = "xy.zzz" % "lib3" % "1.0+" lazy val core=project settings ( name:="cor", libraryDependencies++=Seq(extlib1) ) lazy val servercore=project settings ( name:="srvcore", libraryDependencies++=Seq(extlib1,extlib2) ) dependsOn(core) lazy val masterserver=project settings ( name:="mastersrv", mainClass:=Some("masterserver") ) dependsOn(servercore) lazy val otherserver=project settings ( name:="othersrv", libraryDependencies++=Seq(extlib3), mainClass:=Some("otherserver") ) dependsOn(servercore) // Only for aggregating the builds of the subprojects lazy val root=project in file(".") settings(name:="proj") aggregate( core,servercore,masterserver,otherserver )
Thus, in fact, the project creates several programs ("masterserver", "othererver"), which depend on external libraries and a subset of the subprojects of the project itself.
I want to have the full set of JARs needed to run the main server or another server shared for each. So, I would like to have, for example, masterserver/target/<whatever> containing
mastersrv.jar srvcore.jar (needed by mastersrv.jar) cor.jar (needed by srvcore.jar) lib1.jar (needed by mastersrv and srvcore) lib2.jar (needed by srvcore) <whatever>.jar (further libs needed by lib1 or lib2)
and a otherserver/target/<whatever> with similar content (it should also add lib3.jar , since this is necessary for othersrv.jar .
How to do it? Can I accomplish this with my own package? The stage output in the root project does nothing (because there is no mailClass ?). Issuing masterserver/state gives an error message
> masterserver/stage [error] No such setting/task [error] masterserver/stage [error] ^
I must admit that I do not understand from the documentation of the plugin of the native packer. How can I archive what I want?
Edit: Of course, I am not attached to a directory file. If I get several ZIP files in the main target directory, this is ok too. I only want to have all the subproject dependencies in one place.
Edit 2: Ok, I found out that Play! The framework does exactly what I want. And for this he uses his own sbt package. How can I archive recursive universal packaging of subprojects in non-sbt projects that use Java as a programming language?