3

I have the following build.sbt file.

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"

When I execute the following command sbt assembly-merge-strategy there's an error I don't understand. Any help appreciated.

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
Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
user3803714
  • 5,269
  • 10
  • 42
  • 61

3 Answers3

0

My understanding tells me there's no assembly-merge-strategy task in sbt-assembly plugin (I can only suspect you use that plugin in your build).

Execute assembly as described in https://github.com/sbt/sbt-assembly#assembly-task as "an awesome new assembly task which will compile your project, run your tests, and then pack your class files and all your dependencies into a single JAR file".

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
  • There's a setting key named `assembly-merge-strategy` - https://github.com/sbt/sbt-assembly/blob/5657dacd0325fc7606ace12adadbdcfea22d2d0c/src/main/scala/sbtassembly/Plugin.scala#L26 – Eugene Yokota Aug 06 '14 at 21:05
  • That's correct, but the OP said *"When I execute the following command sbt assembly-merge-strategy"* and hence the answer. – Jacek Laskowski Aug 06 '14 at 22:12
0

There is a setting named assemblyMergeStrategy (aka assembly-merge-strategy). It's just that you won't directly use it. The way sbt-assembly uses it is scoped to assembly task:

mergeStrategy in assembly <<= ....

So here's what you have to do to call it from the shell:

$ sbt assembly::assemblyMergeStrategy
[info] blabla other things...
[info] <function1>
Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
Eugene Yokota
  • 94,654
  • 45
  • 215
  • 319
0

add assemblySettings in your build.sbt will help

shengshan zhang
  • 538
  • 8
  • 16