SBT程序集插件错误

时间:2016-01-12 10:10:14

标签: sbt

我正在尝试在我的项目上运行sbt程序集但是我收到错误说:

[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]         ^

我有以下结构:

MyProject
 - project
   - assembly.sbt
   - build.properties
   - BuildSettings.scala
   - MyProjectBuild.scala
 - src
   - main
     - com
       - mypkg
         - MyMainClass.scala

我的assembly.sbt中有以下内容:

resolvers += Resolver.url("artifactory", url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")

// dont upgrade to 0.12.0 as there is assembly conflict

我的build.properties是:

sbt.version=0.13.6

我的BuildSettings.scala是:

import sbt._
import Keys._

object BuildSettings {

  lazy val basicSettings = Seq[Setting[_]](
    organization  := "com.eon.vpp",
    version       := "0.1.0-SNAPAHOT",
    description   := "vpp metrics producer to a kafka instance",
    scalaVersion  := "2.11.7",
    scalacOptions := Seq("-deprecation", "-encoding", "utf8"),
    resolvers     ++= Dependencies.resolutionRepos
  )

  // sbt-assembly settings for building one fat jar
  import sbtassembly.Plugin._
  import AssemblyKeys._
  lazy val sbtAssemblySettings = assemblySettings ++ Seq(

    jarName in assembly := {
      name.value + "-" + version.value + ".jar"
    },

    // META-INF discarding
    mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
       {
        case PathList("META-INF", xs @ _*) => MergeStrategy.discard
        case x => MergeStrategy.first
       }
    }
  )

  lazy val buildSettings = basicSettings ++ sbtAssemblySettings
}

有关此错误原因的任何建议吗?

1 个答案:

答案 0 :(得分:0)

是的,我弄清楚问题是什么。我不得不将plugins.sbt文件移动到项目文件夹中。就这么简单!