sbt-assembly - cannot set jar-name (and other keys)

734 views
Skip to first unread message

RanUser

unread,
Sep 5, 2011, 4:12:57 AM9/5/11
to simple-build-tool
My attempts below to set the jar-name for a project are ignored:

Snippet from project/build.scala :

val Assembly = config("assembly") extend(Runtime)

val jarName = SettingKey[String]("jar-name")

val assemblySettings: Seq[sbt.Project.Setting[_]] = Seq(
jarName in Assembly := "mycustomjarname.jar"
)

lazy val subProject1= Project (
"subProject1",
file ("subProject1"),
settings = buildSettings ++ Seq (libraryDependencies) ++
assemblySettings
).configs(Assembly).settings(sbtassembly.Plugin.assemblySettings:
_*)

What is wrong here?

Thanks!

Mark Harrah

unread,
Sep 5, 2011, 9:38:26 AM9/5/11
to simple-b...@googlegroups.com

Order matters. If you say:

Seq(
x := 3,
x := 5
)

the second one will override the first and x will be 5.

The project/build.scala listed above does the equivalent of:

Seq(jarName in Assembly := "mycustomjarname.jar") ++
sbtassembly.Plugin.assemblySettings

Because sbtassembly.Plugin.assemblySettings defines jarName, its jarName overrides yours instead of the other way around. So, make your Project definition look like:

lazy val subProject1= Project (
"subProject1",
file ("subProject1"),
settings = buildSettings ++

sbtassembly.Plugin.assemblySettings ++


Seq (libraryDependencies) ++
assemblySettings
)

So, put your customizations last and the defaults first. Also, you don't need to redefine Assembly and jarName. You can import them like normal Scala identifiers:

import sbtassembly.Plugin.{Assembly, jarName}

-Mark

>
> Thanks!
>

RanUser

unread,
Sep 5, 2011, 11:48:23 AM9/5/11
to simple-build-tool
Thanks Mark!
> > Thanks!- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages