sbt mappings in Universal error after sbt upgrade to 0.13.13

604 views Asked by At
mappings in Universal <++= (packageBin in Compile, sourceDirectory) map { (_, src) =>
  val confFiles = (src / "main" / "resources") ** "*.conf"
  confFiles.get.map(file => file -> ("conf/" + file.name))
},

Works but generates a compiler warning <++= has been deprecated. Changing the operator to ++= generates a compiler error

error: No implicit for Append.Values[Seq[(java.io.File, String)], sbt.Def.Initialize[sbt.Task[Seq[(java.io.File, String)]]]] found, so sbt.Def.Initialize[sbt.Task[Seq[(java.io.File, String)]]] cannot be appended to Seq[(java.io.File, String)] mappings in Universal ++= (packageBin in Compile, sourceDirectory) map { (_, src) =>

2

There are 2 answers

1
jkinkead On

This operator is very confusing. Try a simpler := which is functionally equivalent:

mappings.in(Universal) := {
  // Dependency on packageBin (part of your previous definition).
  packageBin.in(Compile).value
  // Create the new mappings.
  val confFiles = (sourceDirectory.value / "main" / "resources") ** "*.conf"
  val newMappings = confFiles.get.map(file => file -> ("conf/" + file.name))
  // Append them manually to the previous value.
  mappings.in(Universal).value ++ newMappings
}
0
scout On

Here is how I solved it

mappings in Universal ++= { (packageBin in Compile, sourceDirectory) map { (_, src) =>
val confFiles = (src / "main" / "resources") ** "*.conf"
confFiles.get.map(file => file -> ("conf/" + file.name))
} 
}.value,

Even better is

mappings in Universal ++= {
val src = sourceDirectory.value
val confFiles = (src / "main" / "resources") ** "*.conf"
confFiles.get.map(file => file -> ("conf/" + file.name))
}