Scala SBT:独立 jar [英] Scala SBT: standalone jar

查看:31
本文介绍了Scala SBT:独立 jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

The answer: Making stand-alone jar with Simple Build Tool seems like what I need, but it did not have enough information for me, so this is a followup.

(1) How do I adapt the answer to my need? I don't understand what would need to be changed.

(2) What command do I run to create the standalone jar?

(3) Where can I find the jar after it has been created?


What I've tried:

  • Pasting the code in the linked answer verbatim into my: project/build/dsg.scala file. The file now has a

    class ForkRun(info: ProjectInfo) extends DefaultProject(info)

    (from before, used for running projects in a separate VM from SBT) and the new:

    trait AssemblyProject extends BasicScalaProject

    from the linked answer.

  • I also tried pasting the body (all defs and the lazy val of the AssemblyProject into the body of ForkRun.

To create a jar I ran package at the SBT prompt and get:

[info] Packaging ./target/scala_2.8.1/dsg_2.8.1-1.0.jar ...
[info] Packaging complete.

So I tried running the dsg_2.8.1-1.0.jar from the shell via:

java -jar dsg_2.8.1-1.0.jar 

But I get:

Failed to load Main-Class manifest attribute from
dsg_2.8.1-1.0.jar

Could this be caused by having multiple entry points into my project? I select from a list when I execute run from the SBT prompt. Perhaps I need to specify the default when creating the package?

解决方案

Here's a writeup I did on one way to make an executable jar with SBT:

http://janxspirit.blogspot.com/2011/01/create-executable-scala-jar-with-sbt.html

这篇关于Scala SBT:独立 jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆