sbt-native-packager无法将NativePackagerKeys._导入Build.scala

时间:2014-11-25 19:12:01

标签: sbt sbt-native-packager

标题说明了一切。我确定这是一个很小的东西,但我已经在这几个小时了,不能让它被舔。

  1. SBT 13.7
  2. sbt-native-packager 1.0.0-M1
  3. 使用AutoPlugins
  4. scala 2.10.4
  5. 使用Build.scala
  6. 使用sbt脚本标准化
  7. 我的project文件夹看起来像这样

    project/
        project/*
        target/*
        Build.scala
        plugins.sbt
    

    plugins.sbt

    addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.0-M1")
    

    Build.scala

    import sbt._
    import Keys._
    
    object BuildSettings {
    
      val buildName = "ASDF"
      val buildOrganization = "BLAH"
      val buildVersion      = "0.1-SNAPSHOT"
      val buildScalaVersion = "2.10.4"
    
      val buildSettings = Defaults.defaultSettings ++ Seq(
        organization  := buildOrganization,
        version       := buildVersion,
        scalaVersion  := buildScalaVersion,
        shellPrompt   := ShellPrompt.buildShellPrompt,
        scalacOptions ++= Seq("-encoding", "utf8", "-unchecked", "-deprecation", "-feature")
      )
    }
    
    object ShellPrompt {
    
    object devnull extends ProcessLogger {
      def info (s: => String) {}
      def error (s: => String) { }
      def buffer[T] (f: => T): T = f
    }
    
    def currBranch = (
      ("git status -sb" lines_! devnull headOption)
      getOrElse "-" stripPrefix "## "
    )
    
    val buildShellPrompt = {
      (state: State) => {
        val currProject = Project.extract (state).currentProject.id
        "%s:%s:%s> ".format (
          currProject, currBranch, BuildSettings.buildVersion
        )
      }
    }
    }
    
    object Packaging {
      import com.typesafe.sbt.SbtNativePackager._
      import NativePackagerKeys._ 
      val packagingSettings = Seq(
        name := BuildSettings.buildName,
        NativePackagerKeys.packageName := "asdf"
      ) ++ Seq(packageArchetype.java_application:_*) ++ buildSettings
     }
    
    object Resolvers {
      val twttrRepo    = "Twitter Repo"  at "http://maven.twtter.com"
      val sonaTypeRepo = "SonaType Repo" at "https://oss.sonatype.org"
    }
    
    object Dependencies {
      val finatra = "com.twitter" %% "finatra" % "1.5.4"
      val finagleHttp = "com.twitter" %% "finagle-http" % "6.2.0"
      val scalaTest = "org.scalatest" % "scalatest_2.10" % "2.0" % "test"
      val argonaut = "io.argonaut" %% "argonaut" % "6.0.4"
    }
    
    object ASDF extends Build {
      import Resolvers._
      import Dependencies._
      import BuildSettings._
    
      val commonDeps = Seq (
        finatra,
        finagleHttp,
        argonaut,
        scalaTest
      )
    
      lazy val root: Project = Project(
       buildName,
       file("."),
       settings = buildSettings ++ Seq(libraryDependencies ++= commonDeps)
        ++ Packaging.packagingSettings
      )
    }
    

    当尝试编译时,吐出

    [error]           /Users/penland365/Development/sabrelabs/projects/CortanaTripCase/server/project/Build.scala:45: not found: value NativePackagerKeys
    [error]   import NativePackagerKeys._
    [error]          ^
    [error] one error found
    [error] (compile:compile) Compilation failed`
    

    我试过移动那些导入语句,但还没有看到任何不同的东西。有任何想法吗?感谢。

1 个答案:

答案 0 :(得分:5)

如果您使用自动插件,建议的格式是使用multi-project build.sbt

要回答你关于密钥的问题,你应该尝试

import com.typesafe.sbt.SbtNativePackager.autoImport._