2015-11-21 12 views
8

Próbuję dokować daną aplikację sieciową i używam sbt-docker. I pojawia się błąd gollowing kiedy wykonać SBT docker:Dlaczego funkcja EnaPlugins (DockerPlugin) z sbt-docker w projekcie Play podaje "błąd: odwołanie do DockerPlugin jest niejednoznaczne"?

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 

otrzymuję powyższy błąd i moja build.sbt wygląda następująco:

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

Mam podejrzenia, że ​​SBT-native Packager jest konflikt z sbt-dockerem. Ale nie importuję sbt-native-packager w żadnym miejscu.

Odpowiedz

1

Jak mówi komunikat "i import _root_.com.typesafe.sbt.packager.docker.DockerPlugin" SBT-native Packager jest wyposażony w konflikcie DockerPlugin klasie. Ale to już wiesz.

Podstępem jest to, że wtyczka Play zależy od pakietu sbt-native-packager, aby ... ułatwić życie ludziom, a co za tym idzie konflikt (przepraszam, zbyt duża pomoc może złamać ludzkie życie :)).

Rozwiązaniem jest użycie w pełni kwalifikowanych nazw klas wtyczek jako polecanych @pfn lub disablePlugins(SbtNativePackager).

Zobacz http://www.scala-sbt.org/sbt-native-packager/topics/play.html.

10

Jeśli wystąpi konflikt, użyj pełnego imienia i nazwiska.

enablePlugins(sbtdocker.DockerPlugin) 
Powiązane problemy