简体   繁体   中英

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._ 
  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:

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

    \nimport AssemblyKeys._  \n\nseq(assemblySettings: _*) \n\nname := "my_project" \n\nversion := "1.0" \n\nscalaVersion := "2.9.1" \n\nlibraryDependencies ++= Seq( \n  "org.scalatest" %% "scalatest" % "1.6.1" % "test", \n  "commons-lang" % "commons-lang" % "2.6" \n) \n\ntraceLevel in run := 0 \n\nfork in run := true \n\nscalacOptions ++= Seq("-optimize") \n\n// The following is the class that will run when the jar is compiled! \n\nmainClass in assembly := Some("MyMain") \n

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

You shouldn't import plugin settings into build.sbt ( basic configuration ): 1) build.sbt is not a normal Scala source file 2) plugin settings are pre-imported.

So you simply should do

seq(assemblySettings: _*)

Imports are required only when you use full/extended build configuration .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM