10

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.

Community
  • 1
  • 1
ovo
  • 448
  • 4
  • 16

2 Answers2

20

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
Community
  • 1
  • 1
Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
  • 1
    Or take a walk on the wild side using sbt 0.13.5 and sbt-native-packager 1.0.0-M1 and just: `enablePlugins(JavaServerAppPackaging)` – Muki Oct 27 '14 at 08:18
  • Whoohoo! I'd say "At long last"! Isn't `enablePlugins` alone part of 0.13.6? – Jacek Laskowski Oct 27 '14 at 08:25
  • AFAIK this is already part of 0.13.5. However this shouldn't matter because 0.13.5 and 0.13.6 should be compatible – Muki Nov 02 '14 at 10:36
  • This looks promising, but I don't believe it is equivalent to the sbt stage plugin that ships with the Play framework, which produces not a OS package, but an uberjar with all dependencies included, which is what I really need. – ovo Nov 05 '14 at 15:32
  • In fact I just added the code below to plugins.sbt and 'sbt stage' works like a charm, generating an uberjar in the target directory: `resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/" The issue now is I have Play's listener trying to grab port 9000, and I already have a service there -- I can configure it for a different port, but I just don't need a listener in this app. // The Play plugin addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.5")` – ovo Nov 05 '14 at 15:41
  • You can do the same with sbt-native-packager and sbt-assembly. http://www.scala-sbt.org/sbt-native-packager/DetailedTopics/custom.html#sbt-assembly – Muki Nov 06 '14 at 11:40
  • Ah, the uberjar thingy - that's what [sbt-assembly](https://github.com/sbt/sbt-assembly) gives you out of the box. Install it and `sbt assembly` gives you the uberjar. That's however not what you've been asking for in the original question. – Jacek Laskowski Nov 06 '14 at 12:34
0

After lots of digging, I found out 'stage' is implemented by a plugin from the Play framework, which I do use in my other projects and explains why sbt was accepting the stage command.

ovo
  • 448
  • 4
  • 16
  • Does this mean that you didn't set up the project properly, i.e. `project/plugins.sbt` without `addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.5")`? – Jacek Laskowski Oct 23 '14 at 21:12
  • Correct. I just don't want to bring the whole Play framework into this other application, which is a backend service without a HTTP interface. – ovo Oct 24 '14 at 01:15
  • Fear not. The plugin changes sbt itself with additional tasks and settings and unless you don't use it in your app explicitly, they don't show up anywhere. – Jacek Laskowski Oct 24 '14 at 06:42