-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use case: single project, multiple apps #633
Comments
The way I handle this is via a |
Submodules are one way to handle this. If you just want different startup scripts you could
#!/bin/bash
you-app-name -main path.to.Main See #319 |
@metasim sweet :) |
@wookietreiber did one of the solutions solve your problem? |
Sorry for not replying sooner, I had to postpone the project I had this feature in mind for a while. Today I dove a bit into sbt tasks and the way I handled it for now is this: val scripts = taskKey[Unit]("Creates the scripts.")
scripts := {
val scriptDir = target.value / "scripts"
if (!scriptDir.exists) scriptDir.mkdir()
val prefix = sys.env.getOrElse("PREFIX", "/usr/local")
def script(clazz: String) =
s"""|#!/bin/sh
|java -cp ${prefix}/share/grid-engine-tools/grid-engine-tools.jar $clazz
|""".stripMargin
(discoveredMainClasses in Compile).value foreach { clazz =>
val app = clazz.drop(clazz.lastIndexOf(".") + 1)
val s = scriptDir / app
IO.write(s, script(clazz))
}
}
scripts <<= scripts dependsOn assembly In the end I realized this wasn't that complicated overall. The one part that is not handled by this snippet is the actual installation and prefix handling which I did with an external Makefile, because there are some other non-Scala bash scripts which also need installation. I always intended the solution to center around the Do you think using If you would like to see the full project, here is a link, both Note: I depend in my example on the sbt assembly task. |
Sorry for the VERY late reply. Building a small archetype plugin for this would generally be a nice idea. Best case would be to just call the initial start script, but with a different main class. |
Looks like this already works in version 1.2.2. |
Thanks for the hint. Indeed this was introduced in 1.2.0 |
As I understand it, from a cursory reading of your documentation, sbt-native-packager considers only a single main class and will create only a single script invoking that main class, is that correct?
The use case I am currently pondering on is having a single project with multiple main classes, i.e. multiple distinct apps, each of which should get its own script, e.g.:
Supposed to be deployed result:
Each of the scripts in
bin
uses the samelib/project.jar
only with a different main class.Is this possible to achieve right now? If not: Is sbt-native-packager able to be extended to support this use case?
The text was updated successfully, but these errors were encountered: