score:0

  1. Create launcher configuration file, e.g. fqb.build.properties in the project's main directory.

  2. Create a script that launches the application

    #!/usr/bin/env bash
    
    java -jar /path/to/sbt-launch.jar "$@"
    
  3. Define task and command:

    lazy val launcherTask = TaskKey[Unit]("launch", "Starts the application from the locally published JAR")
    
    lazy val launchApp: Seq[Setting[_]] = Seq(
        commands += Command.command("publish-launch") { state =>
        state.log.info("Re-launching app")
        val modulesProj = modules.id
        s"$modulesProj/publishLocal" ::
          "publishLocal" ::
          launcherTask.key.label ::
          state
      },
      launcherTask := {
        "launch @fqb.build.properties" !<
      }
    )
    
  4. Add it as a setting to a project:

    lazy val root = Project(
        id       = "app",
        base     = file("."),
        settings = buildSettings ++ Seq( resolvers := rtResolvers,
          libraryDependencies ++= libs,
          scalacOptions  ++= Seq("-encoding", "UTF-8", "-deprecation", "-unchecked"),
          launchApp)
    )
    

Remember to delete old ~/.<app_name> directory when re-deploying, so the changes could take effect.


Related Query

More Query from same tag