3

我有以下build.sbt文件。

import AssemblyKeys._

name := "approxstrmatch"

version := "1.0"

scalaVersion := "2.10.4"

libraryDependencies+="org.apache.spark" %% "spark-core" % "1.0.0"

resolvers += "AkkaRepository" at "http://repo.akka.io/releases/"

// My merge strategy is specified here.

lazy val app = Project("approxstrmatch", file("approxstrmatch"),
    settings = buildSettings ++ assemblySettings ++ Seq(
    mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
    {
        case PathList("javax", "servlet", xs @ _*)         => MergeStrategy.first
        case PathList("javax", "transaction", xs @ _*)     => MergeStrategy.first
        case PathList("javax", "mail", xs @ _*)     => MergeStrategy.first
        case PathList("javax", "activation", xs @ _*)     => MergeStrategy.first
        case PathList(ps @ _*) if ps.last endsWith ".html" => MergeStrategy.first
        case "application.conf" => MergeStrategy.concat
        case "unwanted.txt"     => MergeStrategy.discard
        case x => old(x)
        }
    })
  )

mainClass in assembly := Some("approxstrmatch.JaccardScore")
// jarName in assembly := "approstrmatch.jar"

当我执行以下命令sbt assembly-merge-strategy时,出现了一个我不明白的错误。任何帮助表示赞赏。

approxstrmatch]$ sbt assembly-merge-strategy
[info] Loading project definition from /apps/sameert/software/approxstrmatch/project
[info] Set current project to approxstrmatch (in buildfile:/apps/sameert/software/approxstrmatch/)
[error] Not a valid command: assembly-merge-strategy
[error] No such setting/task
4

3 回答 3

0

有一个名为assemblyMergeStrategy(aka assembly-merge-strategy) 的设置。只是你不会直接使用它。sbt-assembly 使用它的方式仅限于assembly任务:

mergeStrategy in assembly <<= ....

因此,从 shell 调用它需要执行以下操作:

$ sbt assembly::assemblyMergeStrategy
[info] blabla other things...
[info] <function1>
于 2014-08-06T21:02:40.277 回答
0

我的理解告诉我sbt-assembly插件中没有assembly-merge-strategy任务(我只能怀疑您在构建中使用了该插件)。

按照https://github.com/sbt/sbt-assembly#assembly-task中的assembly描述执行“一个很棒的新组装任务,它将编译您的项目,运行您的测试,然后将您的类文件和所有依赖项打包到一个单个 JAR 文件”

于 2014-08-06T13:59:37.570 回答
0

添加assemblySettings你的 build.sbt 会有所帮助

于 2017-11-16T15:49:00.820 回答