如何将组件插件添加到SBT构建?

时间:2015-10-23 15:15:39

标签: scala sbt sbt-assembly

我正在尝试使用sbt程序集插件来编译我的scala代码。当我将它打包到snapshot.jar时,它运行良好。但是当我尝试添加程序集插件并将其编译为assembly.jar时,我遇到了问题。任何人都可以帮我吗?

tong@tong-VirtualBox:/usr/local/jars/hello/hello$ sbt package
[info] Set current project to hello (in build file:/usr/local/jars/hello/hello/)
[info] Packaging /usr/local/jars/hello/hello/target/scala-2.10/hello_2.10-0.1-SNAPSHOT.jar ...
[info] Done packaging.
[success] Total time: 1 s, completed Oct 23, 2015 10:02:52 AM

sbt-assembly我得到了

tong@tong-VirtualBox:/usr/local/jars/hello/hello$ addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.13.0")
bash: syntax error near unexpected token `"com.eed3si9n"'

2 个答案:

答案 0 :(得分:1)

命令addSbtPlugin不是unix命令,不能在 Linux shell中运行。一般来说,它是一个SBT命令(或任务,现在不确定),只能在SBT中使用。 (尝试一下,只需从shell / bash中运行sbt即可进入SBT控制台。

因此,在您的情况中,addSbtPlugin ....需要放在' .sbt'文件,首选位置是' plugin.sbt`,在您的项目中将插件添加到您的构建环境中。请您参考SBT tutorial pages on using plugins

一般

答案 1 :(得分:1)

sbt-assembly项目页面上,有关如何安装/使用插件的相当简洁的解释。

为了让您快速上手,您只需将以下代码段添加到$PROJECT_ROOT/project/assembly.sbt

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.0")

然后从shell开始组装阶段,如下所示:

$ cd $PROJECT_ROOT
$ sbt assembly

为了避免依赖性问题(如sbt-assembly项目页面中所述),使用sbt version> = 0.13.6会更好。您可以通过在$PROJECT_ROOT/build.properties中添加以下内容来强制执行此操作:

sbt.version=0.13.8
相关问题