sbt-native-packager cannot import NativePackagerKeys._ into Build.scala

1.8k views Asked by At

The title says it all. I'm sure this is something small, but I've been on this for a few hours and can't get it licked.

  1. SBT 13.7
  2. sbt-native-packager 1.0.0-M1
  3. Using AutoPlugins
  4. scala 2.10.4
  5. using Build.scala
  6. using an sbt script to standardize

My project folder looks like this

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
  )
}

Which, when compilation is attempted, spits out

[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`

I've tried moving those import statements around, but have yet to see anything different. Any ideas? Thanks.

1

There are 1 answers

1
Eugene Yokota On

If you're using auto plugin, the recommended style is to use multi-project build.sbt.

To answer your question on keys, you should probably try

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