Making a conscripted app 

We hope you’ll make your own apps that use conscript.


The ConscriptPlugin makes these easier to build and test. Add this to the following project/conscript.sbt:

addSbtPlugin("org.foundweekends.conscript" % "sbt-conscript" % "0.5.8")

Next enable ConscriptPlugin on the app subproject in build.sbt:

lazy val root = (project in file(".")).
    // other settings here

The plugin brings in a “provided” dependency to sbt launcher-interface.

Entry point 

Make the entry point to your app by implementing xsbti.AppMain.

package example

class HelloApp extends xsbti.AppMain {
  def run(configuration: xsbti.AppConfiguration): xsbti.MainResult = {
    // get the version of Scala used to launch the application
    val scalaVersion = configuration.provider.scalaProvider.version

    // Print a message and the arguments to the application
    println("Hello world!  Running Scala " + scalaVersion)

    new Exit(0)
  class Exit(val code: Int) extends xsbti.Exit

After one or two command line options, you might want to take a look at scopt to do commandline parsing.


Next, add your sbt launchconfig file to src/main/conscript/XYZ/launchconfig (substitue XYZ with your script name such as g8 and cs):

  version: 0.1.0
  org: com.example
  name: hello
  class: example.HelloApp
  version: 2.11.12

To learn more about the launchconfig, see sbt Launcher section of the sbt Reference Manual.


You can test the app by calling csRun XYZ command.