SBT assembly issue: found String required sbt.Task[String] with <<= syntax

905 Views Asked by At

I'm a long-term and happy user of sbt-assembly, but I've encountered a problem when using SBT 0.13.0 & sbt-assembly 0.10.1 on a new project.

I have previously used code like this:

import sbtassembly.Plugin._
import AssemblyKeys._
lazy val sbtAssemblySettings = assemblySettings ++ Seq(
  // Slightly cleaner jar name
  jarName in assembly <<= (name, version) { (name, version) => name + "-" + version + ".jar" }
)

lazy val buildSettings = ... ++ sbtAssemblySettings

This has worked fine for me in previous versions of SBT/sbt-assembly, but I'm now getting the error:

type mismatch;
[error]  found   : String
[error]  required: sbt.Task[String]
[error]     jarName in assembly <<= (name, version) { (name, version) => name + "-" +   version + ".jar" }
[error]                                                                                           ^
[error] one error found

For completeness: the full project is available here.

I can't help wondering is this issue is related to the New task/setting syntax in SBT 0.13.0:

First, the old syntax is still supported with the intention of allowing conversion to the new syntax at your leisure. There may be some incompatibilities and some may be unavoidable, but please report any issues you have with an existing build.

Any help gratefully received!

1

There are 1 best solutions below

1
On BEST ANSWER

It's not sbt 0.13, it's sbt-assembly. I accepted a pull req that changed the jarName from setting to task at 0.8.8:

breaking: jarName is now a task

Good news for those who want to generate jar names dynamically. Thanks to @dchenbecker, jarName in assembly is now a task #74.

Using sbt 0.13 syntax you don't have to worry about the task/setting difference any more:

jarName in assembly := {
  name.value + "-" + version.value + ".jar"
}