running sbt class using only a jar

411 views Asked by At

Is there any way to run sbt commands with only a jar instead of a project?

I've been having issues using scopt with java or scala commands, and it only seems to work with sbt.

Ideally something like

sbt --jar <jar name>/"run-main <options"
1

There are 1 answers

0
jvliwanag On

You'd probably want to package everything up into something you can execute. One possibility would be to create a fat jar using something like sbt-assembly.

Once you've built your jar, you can then:

java -jar /path/to.jar --your-options

Take note that at this point you can only do what would have been the equivalent of sbt run-main with the jar. You cannot of course invoke any of the other sbt commands on the jar created.