【问题标题】:How to add assembly plugin to SBT build?如何将程序集插件添加到 SBT 构建?
【发布时间】:2015-10-24 19:08:45
【问题描述】:

我正在尝试使用 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"'

【问题讨论】:

    标签: scala sbt sbt-assembly


    【解决方案1】:

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

    为了让您快速上手,您只需将以下 sn-p 添加到您的$PROJECT_ROOT/project/assembly.sbt

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

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

    $ cd $PROJECT_ROOT
    $ sbt assembly
    

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

    sbt.version=0.13.8
    

    【讨论】:

      【解决方案2】:

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

      所以在您的情况中,addSbtPlugin .... 需要放在一个“.sbt”文件中,首选位置是“plugin.sbt”,在您的项目中将插件添加到您的构建环境.敬请参考SBT tutorial pages on using plugins

      一般来说

      【讨论】:

        猜你喜欢
        • 2016-01-20
        • 2017-07-04
        • 2016-02-07
        • 2016-10-06
        • 2014-11-01
        • 2013-03-15
        • 2011-09-27
        • 2014-09-21
        • 2015-01-26
        相关资源
        最近更新 更多