2015-11-21 19 views
8

私は遊びWebアプリケーションをドッキングしようとしていますが、私はsbt-dockerを使用しています。私は、SBTのドッキングウィンドウを実行したとき、私はgollowingエラーを取得:Playプロジェクトのsbt-dockerのenablePlugins(DockerPlugin)が「エラー:DockerPluginへの参照があいまいですか」という理由は何ですか?

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 
enablePlugins(DockerPlugin) 
      ^
[error] Type error in expression 
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? q 

私は上記のエラーを取得し、私のbuild.sbtは、次のようになります。

enablePlugins(DockerPlugin) 

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

scalaVersion := "2.11.6" 

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

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

// Play provides two styles of routers, one expects its actions to be injected, the 
// other, legacy style, accesses its actions statically. 
routesGenerator := InjectedRoutesGenerator 

// Make docker depend on the package task, which generates a jar file of the application code 
docker <<= docker.dependsOn(sbt.Keys.`package`.in(Compile, packageBin)) 

// Define a Dockerfile 
dockerfile in docker := { 
    val jarFile = artifactPath.in(Compile, packageBin).value 
    val classpath = (managedClasspath in Compile).value 
    val mainclass = mainClass.in(Compile, packageBin).value.getOrElse(sys.error("Expected exactly one main class")) 
    val jarTarget = s"/app/${jarFile.getName}" 
    // Make a colon separated classpath with the JAR file 
    val classpathString = classpath.files.map("/app/" + _.getName).mkString(":") + ":" + jarTarget 
    new Dockerfile { 
    // Base image 
    from("java") 
    // Add all files on the classpath 
    add(classpath.files, "/app/") 
    // Add the JAR file 
    add(jarFile, jarTarget) 
    // On launch run Java with the classpath and the main class 
    entryPoint("java", "-cp", classpathString, mainclass) 
    } 
} 

私の疑いがSBT-ネイティブパッケージャがあるということですsbt-dockerと競合しています。しかし、私はどこでもsbt-native-packagerをインポートしていません。

答えて

1

メッセージが言うように"と輸入_root_.com.typesafe.sbt.packager.docker.DockerPlugin" SBT-ネイティブパッケージャは、競合DockerPluginクラスが付属しています。しかし、それはあなたがすでに知っていることです。

Playプラグインはsbt-native-packagerに依存しているため、人の命を救済し、競合を緩和します(申し訳ありませんが、あまりにも多くの人の命を救うかもしれません:))。

解決策は、@ pfn recommendedまたはdisablePlugins(SbtNativePackager)の完全修飾プラグインクラス名を使用することです。

http://www.scala-sbt.org/sbt-native-packager/topics/play.htmlを参照してください。

10

競合が発生した場合は、フルネームを使用してください。

enablePlugins(sbtdocker.DockerPlugin) 
関連する問題