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

查看:96
本文介绍了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)如何使答案适应我的需要?我不知道需要更改什么.

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

(2)我要运行什么命令来创建独立的jar?

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

(3)创建罐子后,在哪里可以找到?

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

我尝试过的事情:

  • 将链接的答案中的代码逐字粘贴到我的project/build/dsg.scala文件中.该文件现在有一个

  • 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)

(从以前开始,用于在与SBT不同的VM中运行项目)和新的:

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

trait AssemblyProject extends BasicScalaProject

来自链接的答案.

我还尝试将主体(AssemblyProject的所有defslazy val都粘贴到ForkRun的主体中.

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

要创建一个jar,我在SBT提示符下运行了package并得到:

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.

所以我尝试通过以下命令从外壳运行dsg_2.8.1-1.0.jar:

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 

但是我得到了

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

这可能是由于我的项目中有多个入口点引起的吗?当我从SBT提示符执行run时,从列表中选择.也许我在创建程序包时需要指定默认值?

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?

推荐答案

这是我用一种方法制作的带有SBT的可执行jar的文章:

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:独立罐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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