Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 947
Alex Dean Avatar asked Jan 23 '26 11:01

Alex Dean


1 Answers

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"
}
like image 92
Eugene Yokota Avatar answered Jan 27 '26 01:01

Eugene Yokota



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!