Search code examples
sbtsbt-native-packager

Why does "sbt stage" fail with Not a valid command?


I am getting errors when I try to stage my application using sbt clean compile stage:

[error] Not a valid command: stage
[error] Not a valid project ID: stage
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: stage
[error] stage
[error]      ^

I have done this hundreds of times on other machines without a problem. I have SBT 0.13.5 -- has anyone seen this before? I have read this other post, but I'm not on Heroku. Thanks.


Solution

  • After the comments above I realized that you just wanted to have stage command without bringing the entire Play foo in.

    The stage command is part of sbt-native-packager that:

    The goal [of the plugin] is to be able to bundle up Scala software built with SBT for native packaging systems, like deb, rpm, homebrew, msi.

    One of the features of the sbt-native-packager plugin is the stage command that

    > help stage
    Create a local directory with all the files laid out as they would be in the final distribution.
    

    Just add the following to project/plugins.sbt to have the plugin available in the project (after the comment of Muki the example uses the latest version 1.0.0-M1 with the autoplugin feature):

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

    You will also have to add the following to build.sbt:

    enablePlugins(JavaAppPackaging)
    

    And that's it! You're all set now.

    Execute stage.

    > stage
    [info] Packaging /Users/jacek/dev/sandbox/command-build-scala/target/scala-2.10/command-build-scala_2.10-0.1-SNAPSHOT-sources.jar ...
    [info] Done packaging.
    [info] Updating {file:/Users/jacek/dev/sandbox/command-build-scala/}command-build-scala...
    [info] Wrote /Users/jacek/dev/sandbox/command-build-scala/target/scala-2.10/command-build-scala_2.10-0.1-SNAPSHOT.pom
    [info] Resolving org.fusesource.jansi#jansi;1.4 ...
    [info] Done updating.
    [info] Packaging /Users/jacek/dev/sandbox/command-build-scala/target/scala-2.10/command-build-scala_2.10-0.1-SNAPSHOT-javadoc.jar ...
    [info] Done packaging.
    [info] Packaging /Users/jacek/dev/sandbox/command-build-scala/target/scala-2.10/command-build-scala_2.10-0.1-SNAPSHOT.jar ...
    [info] Done packaging.
    [success] Total time: 0 s, completed Nov 5, 2014 2:55:55 PM