So using Scala Play Framework. I have a single codebase but need to launch it 2 ways. One way will launch with Play Netty as the main class, and run a webserver. A second way will run my own main class and do different things.
If I do play dist (https://www.playframework.com/documentation/2.3.x/ProductionDist)
It ends up using the sbt-native plugin, and make a new zip. Inside that zip is a script that calls java with a mainclass of Netty. This is ultimately coming from
mainClass in (Compile, run) := Some("play.core.server.NettyServer"),
inside of PlaySettings.scala.
I want to keep all of this, but add a second artifact to dist.. that has the only different of a different main class.
I started trying to make subprojects.. but not sure this is what I really even want. Something like:
lazy val root = Project( id = "root", base = file("."), librar aggregate = Seq(web, backend) ).dependsOn(web, worker) lazy val web = Project( id = "web", base = file("."), settings = packageArchetype.java_server ++ Seq( name := "web", mainClass in Compile := Some("play.core.server.NettyServer") ) ).enablePlugins(PlayScala) lazy val backend= Project( id = "backend", base = file("."), settings = packageArchetype.java_server ++ Seq( name := "backend", mainClass in Compile := Some("com.foobar.BackendMain") ) )
But I only end up with a single artifact still. What other options are there?
I could hack up bash-template and add mainClass as a parameter and pass it through to the launch script...