5

I'm trying to use JavaAppPackaging from sbt-native-packager. My understanding is, that when I run:

sbt stage

I should get a directory target/universal/stage/bin with some startup scripts. Now I only get lib which contains my jar and it's dependencies.

Here's the relevant parts of my build.sbt:

val scalatra = "org.scalatra" %% "scalatra" % "2.3.1"

enablePlugins(JavaAppPackaging)

lazy val root = (project in file(".")).
  settings(
    name := "myapp",
    version := "0.2",
    scalaVersion := "2.11.6",
    libraryDependencies += scalatra
  )

Also, my plugins.sbt has this:

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

I'm using sbt 0.13.8.

So why don't I get the startup scripts, what am I missing?

auramo
  • 13,167
  • 13
  • 66
  • 88

2 Answers2

4

You need make sure sbt finds a main for the script.

This could mean either make sure you have a main: an object that extends App or one that defines a def main(args: Array[String]): Unit.

Otherwise try setting mainClass, like so:

 mainClass in Compile := Some("JettyLauncher")
Dale Wijnand
  • 6,054
  • 5
  • 28
  • 55
  • I have a class with main. Do I have to tell sbt which one is it somehow? – auramo May 24 '15 at 05:13
  • At least this didn't help: mainClass in (Compile, run) := Some("JettyLauncher") – auramo May 24 '15 at 06:35
  • @auramo Hmm ok, then you need to provide more detail as with what you have currently + a simple App `stage` will generate the scripts. – Dale Wijnand May 24 '15 at 07:56
  • Changed it to mainClass in (Compile) := Some("JettyLauncher"), and ran sbt clean, then sbt stage. Now it worked! Don't know which of the changes did the trick. Anyway, thanks for setting me on the right path! – auramo May 25 '15 at 05:10
  • `mainClass in (Compile, run)` sets the main class only in the Compile-Configuration _and_ during the `run` task. When you run the `stage` task there is still no main class set. – Muki Jun 04 '15 at 16:44
1

Try setting the main class without any scopes: mainClass := Some ("full.path.to.MainApp")

Muki
  • 3,513
  • 3
  • 27
  • 50