无法解析与docker相关的sbt标记

时间:2016-11-30 03:16:30

标签: scala docker playframework sbt sbt-docker

我正在尝试将sbt-docker添加到我的Play网站的sbt版本中,但我遇到了一个问题。由于某些原因,底部的Docker相关内容都无法解决。

项目/ plugins.sbt

logLevel := Level.Warn

resolvers ++= Seq(
    "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
)

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.9")

build.sbt

name := "personal_site"

version := "1.1"

lazy val `personal_site` = (project in file(".")).enablePlugins(PlayScala,DockerPlugin)

scalaVersion := "2.11.7"

libraryDependencies ++= Seq( jdbc , cache , ws , specs2 % Test )

unmanagedResourceDirectories in Test <+=  baseDirectory ( _ /"target/web/public/test" )  

resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases"

dockerfile in docker := {
    val targetDir = "/usr/src"

    new Dockerfile {
        from("flurdy/activator")
        //More goes here
    }
}

imageNames in docker := Seq(
    // Sets the latest tag
    ImageName(s"${name.value}:latest"),

    // Sets a name with a tag that contains the project version
    ImageName(
        namespace = None,
        repository = name.value,
        tag = Some("v" + version.value)
    )
)

这是IntelliJ

中的图片

enter image description here

我也尝试将addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.4.0")添加到project/plugins.sbt,但我收到有关DockerPlugin被导入两次的错误。

~/Sync/Projects/Programming/Personal_Site (master ✘)✹ ᐅ  sbt clean
[info] Loading project definition from /home/ryan/Sync/Projects/Programming/Personal_Site/project
/home/ryan/Sync/Projects/Programming/Personal_Site/build.sbt:5: error: reference to DockerPlugin is ambiguous;
it is imported twice in the same scope by
import _root_.sbtdocker.DockerPlugin
and import _root_.com.typesafe.sbt.packager.docker.DockerPlugin
lazy val `personal_site` = (project in file(".")).enablePlugins(PlayScala,DockerPlugin)

1 个答案:

答案 0 :(得分:1)

尝试将build.sbt配置更改为此。

lazy val root = (project in file(".")).enablePlugins(sbtdocker.DockerPlugin, PlayScala)

它通过使用DockerPlugin的全名来消除歧义,因为sbt-native-packager对我的Docker插件使用了相同的名称。

也许值得为作者的回购提出一个Github问题,以便他们可以在项目文档中记录它。