sbt assembly command not found
Asked Answered
A

7

37

I'm trying to run sbt assembly. According to https://github.com/sbt/sbt-assembly , for sbt 0.13.6+ (I'm on 0.13.7) this should be included automatically for anything with the JvmPlugin. According to sbt plugins I have the JvmPlugin enabled in root. When I run sbt assembly I get "Not a valid commamdn: assembly". I've tried using old methods of including sbt-assembly with all the different types of sbt configurations, but none seem to work. Here's what my build files look like (note sbt package works fine)

assembly.sbt

addSbtPlugin("com.eed3si8n" % "sbt-assembly" % "0.13.0")

build.sbt

lazy val commonSettings = Seq(
  organization := "com.test",
  version := "1.0",
  scalaVersion := "2.10.4"
)

lazy val root = (project in file(".")).
  settings(commonSettings: _*).
  settings(
    name := "test",

    resolvers ++= Seq(
      ...
    ),

    libraryDependencies ++= Seq(
      ...
    )
)

Here is the error:

[error] Not a valid command: assembly
[error] Not a valid project ID: assembly
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: assembly
[error] assembly
[error]     

Any ideas? Running on Linux. Thanks

Ashil answered 8/4, 2015 at 19:29 Comment(0)
H
32

Did you create a assembly.sbt at the root of your project? Alongside your build.sbt?

If so, then that's the problem. You want to have it inside the project directory.

Having done that it worked out the box as expected with the rest of your setup:

> assembly
[info] Including: scala-library.jar
[info] Checking every *.class/*.jar file's SHA-1.
[info] Merging files...
[warn] Merging 'META-INF/MANIFEST.MF' with strategy 'discard'
[warn] Strategy 'discard' was applied to a file
[info] SHA-1: 1ae0d7a9c433e439e81ce947659bf05aa62a2892
[info] Packaging /Users/dnw/Desktop/t-2015-04-08.2340/target/scala-2.10/test-assembly-1.0.jar ...
[info] Done packaging.
[success] Total time: 2 s, completed 08-Apr-2015 23:45:59
Hartmunn answered 8/4, 2015 at 22:46 Comment(1)
In my case, the sbt.version in the build.properties file in the project directory wasn't set to 0.13.16 . After setting it properly, the error went away.Static
Q
2

Since the introduction of auto plugins in 0.13.5, adding explicit .sbt files for plugins (except for specific cases where the plugin does not implement auto-plugin trait) is not recommended per sbt documentation.

Add the addSbtPlugin("com.eed3si8n" % "sbt-assembly" % "0.13.0") back to plugins.sbt under project directory and remove assembly.sbt. if you still see the error, explicitly enable the plugin in the build.sbt:

lazy val root = (project in file(".")).
  settings(commonSettings: _*).
  settings(
    name := "test",
  ).
  enablePlugins(AssemblyPlugin)
Quip answered 24/6, 2016 at 11:3 Comment(0)
H
2
lazy val root = (project in file(".")).
  settings(commonSettings: _*).
  settings(
    assemblySettings ++ Seq(
    jarName in assembly := "roobricks-spark.jar",
    test in assembly := {}
  ).
  enablePlugins(AssemblyPlugin)

can you once with this.

Haroldharolda answered 24/6, 2016 at 13:0 Comment(0)
R
2

Same thing happened to me. Move assembly.sbt from the root to inside your project/ directory

Rafaellle answered 17/4, 2019 at 14:20 Comment(0)
A
1

Came across the same error. The reason was I executing it from the wrong inside target folder

Aleen answered 23/2, 2018 at 13:24 Comment(1)
I got your same error as Jonathan, and when I cd into the stixloader folder, and ran the command, it worked better. However I still got an error: download failed: org.slf4j#slf4j-api;1.7.25!slf4j-api.jar. The solution I found on the web was to just run the command once more. It then was able to download slf4j and it then proceeded create the stixloader-1.1.jar.Turf
M
1

You should normally have a plugins.sbt file at the root level alongside your build.properties where you should have the following:

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0")
Mormon answered 1/4, 2021 at 9:57 Comment(0)
X
0

From sparkour:

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.4") with assembly.plugin does work

Xanthous answered 20/1, 2018 at 12:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.