Question

Today I integrated sbt-native-packager into my scala project, mostly to generate handy execution scripts and/or packages.

Now, I added to my build.sbt line:

packageArchetype.java_application

and to my plugins.sbt

resolvers += "sbt-plugins" at "http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.7.0-RC2")

when I invoke sbt stage I get the target/universal/stage directory, but there is only lib there, no bin with scripts (which according to http://www.scala-sbt.org/sbt-native-packager/GettingStartedApplications/MyFirstProject.html should be created).

Do I need to add something else to get bin directory with scripts?

Was it helpful?

Solution

The issue was that in my project I had multiple main clases. In build.sbt I had:

Keys.mainClass in (Compile, run) := Some("Rest")

which should be

Keys.mainClass in (Compile) := Some("Rest")

and now it works perfectly.

OTHER TIPS

On a side note, changing the configuration of the mainClass affects in-sbt running of the application. In order to configure your build to both run the application in sbt (e.g. during development) as well as create packages, you will need 2 mainClass definitions (in build.sbt):

mainClass in Compile := Some("MyBootKernel")

mainClass in (Compile, run) := Some("MyApp")

Where the 2 main classes are:

class MyBootKernel extends Bootable {
  def startup = { MyApp.main(Array()) }
  def shutdown = {}
}

and

object MyApp extends App {
    // initialize application.
}

The start script in the bin directory passes the app main class to akka microkernel, which must extend Bootable (which then initializes the app), while running from sbt directly doesn't need boot stuff (i.e. just the App directly).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top