SBT project for java executable jar

偶尔善良 提交于 2019-12-02 23:59:53
Thomas Lockney

Use the assembly-sbt plugin (originally created by Coda Hale, now maintained by Eugene Yokota): https://github.com/sbt/sbt-assembly

Once you add this to your project it will build a so-called "fatjar" which is executable via java -jar projectName-assembly.jar. It will autodetect your main method -- if there is more than one in your source, you can explicitly set which one to use by setting mainclass, e.g.:

mainClass in assembly := Some("com.package.ClassNameWithMain")

Note: I edited this answer to be up-to-date with the current release of SBT (0.11+).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!