Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

installing sbt-assembly with sbt 0.11.2

I am trying to install sbt-assembly by following the instructions in order to make a stand-alone jar that can run on a computer without scala installed.

So far these are the steps I've taken.

I created a plugins.sbt file:

$ cat sbt/project/plugins.sbt 
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.7.2")

And I added the following to the beginning of my build.sbt file:

$ head -n3 sbt/build.sbt 
import AssemblyKeys._ // put this at the top of the file

seq(assemblySettings: _*)

But when I run sbt, I get the following error:

sbt/build.sbt:1: error: not found: value AssemblyKeys
import AssemblyKeys._ 
like image 761
dsg Avatar asked Dec 12 '11 06:12

dsg


People also ask

How can I change sbt version?

In the Project tool window, in the source root directory, locate the build. properties file and open it in the editor. In the editor explicitly specify the version of sbt that you want to use in the project.

What is sbt Assembly?

The sbt-assembly plugin is an SBT plugin for building a single independent fat JAR file with all dependencies included. This is inspired by the popular Maven assembly plugin, which is used to build fat JARs in Maven.

How do I install sbt plugins?

sbt/1.0. Make a directory called “plugins” in that folder by typing: mkdir plugins. Copy the existing “plugins. sbt” file from the 0.13 directory to the current 1.0 directory by typing the following: cp ../0.13/plugins/plugins.


2 Answers

  1. Make sure you are running sbt version at least 0.11 by typing

    $ sbt sbt-version

    at the bash prompt.

  2. Make sure you have the plugins file set up as follows:

    $ cat sbt/project/plugins.sbt
    
    addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.7.2")
    
  3. Make your build file (build.sbt) look like this:

    import AssemblyKeys._ 
    
    seq(assemblySettings: _*)
    
    name := "my_project"
    
    version := "1.0"
    
    scalaVersion := "2.9.1"
    
    libraryDependencies ++= Seq(
      "org.scalatest" %% "scalatest" % "1.6.1" % "test",
      "commons-lang" % "commons-lang" % "2.6"
    )
    
    traceLevel in run := 0
    
    fork in run := true
    
    scalacOptions ++= Seq("-optimize")
    
    // The following is the class that will run when the jar is compiled!
    
    mainClass in assembly := Some("MyMain")
    
like image 52
dsg Avatar answered Oct 16 '22 17:10

dsg


Make sure you don't have a project/plugins folder lying around. This may prevent other mechanisms of specifying plugins from working.

like image 3
jrudolph Avatar answered Oct 16 '22 16:10

jrudolph