Coinnigh
Coinnigh

Reputation: 619

How to fix the error about sbt in the idea IDE?

I met a strange error in the idea IDE of the sbt, the merge strategy is as follows,

mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
  {
    case m if m.toLowerCase.endsWith("manifest.mf") => MergeStrategy.discard
    case m if m.startsWith("META-INF") => MergeStrategy.discard
    case PathList("javax", "servlet", xs @ _*) => MergeStrategy.first
    case PathList("org", "apache", xs @ _*) => MergeStrategy.first
    case PathList("org", "jboss", xs @ _*) => MergeStrategy.first
    case "about.html"  => MergeStrategy.rename
    case "reference.conf" => MergeStrategy.concat
    case _ => MergeStrategy.first
  }
}

It seems fine, but unfortunately, the IDE complains one error, it is

Cannot resolve reference <<= with such signature
Type mismatch,expected:Def.Initialize[(String) => Plugin.MergeStrategy],  
actual:Def.Initialize[Any].

Anyone can explain this to me and how to fix this issue please?

Upvotes: 1

Views: 546

Answers (1)

Yuval Itzchakov
Yuval Itzchakov

Reputation: 149558

mergeStrategy (and the <<= operator) is deprecated. Use assemblyMergeStrategy instead:

assemblyMergeStrategy in assembly := {
  case m if m.toLowerCase.endsWith("manifest.mf") => MergeStrategy.discard
  case m if m.startsWith("META-INF") => MergeStrategy.discard
  case PathList("javax", "servlet", xs@_*) => MergeStrategy.first
  case PathList("org", "apache", xs@_*) => MergeStrategy.first
  case PathList("org", "jboss", xs@_*) => MergeStrategy.first
  case "about.html" => MergeStrategy.rename
  case "reference.conf" => MergeStrategy.concat
  case s => MergeStrategy.defaultMergeStrategy(s)
}

Upvotes: 1

Related Questions