Why is the error "Invalid command: build-merge-strategy"?
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
, I don't understand the error. Any help was 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
source to share
My understanding is telling me that there is no assembly-merge-strategy
task in the sbt-assembly plugin (I can only suspect that you are using this plugin in your assembly).
Execute assembly
as described at https://github.com/sbt/sbt-assembly#assembly-task as "an awesome new build task that will compile your project, run your tests, and then package your class files and all your dependencies into one JAR file".
source to share
There is a setting named assemblyMergeStrategy
(aka assembly-merge-strategy
). It's just that you won't be using it directly. The way to use sbt-assembly is task specific assembly
:
mergeStrategy in assembly <<= ....
So, here's what you need to do to call it from the shell:
$ sbt assembly::assemblyMergeStrategy [info] blabla other things... [info] <function1>
source to share