Scala – How to run a sbt-managed application project without sbt

sbtscala

My question is about running an application that's in a project managed by sbt 0.10.1 and hence relies on its automatic dependency management (to download and set up appropriate classpath to run).

When using the automatic dependency management, it appears that the only way to run the application is using sbt itself because it knows how to set up the classpath (with a help of Ivy2).

How can I run the application without sbt?

Best Answer

You can also use Typesafe's xsbt-start-script-plugin (edit: now sbt-start-script) to generate a shell script with the correct class path:

This plugin allows you to generate a script target/start for a project. The script will run the project "in-place" (without having to build a package first).

The target/start script is similar to sbt run but it doesn't rely on SBT. sbt run is not recommended for production use because it keeps SBT itself in-memory. target/start is intended to run an app in production.

The plugin adds a task start-script which generates target/start. It also adds a stage task, aliased to the start-script task.

This is what Heroku uses to run Scala apps.

Related Topic