使用sbt-native-packager构建docker包时重复映射

时间:2015-09-24 12:08:11

标签: scala docker sbt sbt-native-packager akka-http

我正在使用sbt-native-packager在Scala中构建基于Akka HTTP的应用程序的docker镜像。但是,最近它在运行sbt docker:publishLocal命令时开始抛出以下错误:

  [info] Loading project definition from ~/directory/project
  [info] Set current project to fortytwo-api (in build file:~/directory/)
  SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
  SLF4J: Defaulting to no-operation (NOP) logger implementation
  SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
  [info] Wrote ~/directory/target/scala-2.11/fortytwo-api_2.11-1.0.pom
  java.lang.RuntimeException: Duplicate mappings:
    ~/directory/target/docker/stage/opt/docker/lib/org.scalaz.scalaz-core_2.11-7.1.0.jar
  from
    ~/.ivy2/maven-cache/org/scalaz/scalaz-core_2.11/7.1.0/scalaz-core_2.11-7.1.0.jar
      ~/.ivy2/cache/org.scalaz/scalaz-core_2.11/bundles/scalaz-core_2.11-7.1.0.jar
    ~/directory/target/docker/stage/opt/docker/lib/com.typesafe.config-1.2.1.jar
  from
    ~/.ivy2/maven-cache/com/typesafe/config/1.2.1/config-1.2.1.jar
      ~/.ivy2/cache/com.typesafe/config/bundles/config-1.2.1.jar
    ~/directory/target/docker/stage/opt/docker/lib/com.google.protobuf.protobuf-java-2.5.0.jar
  from
    ~/.ivy2/maven-cache/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.jar
      ~/.ivy2/cache/com.google.protobuf/protobuf-java/bundles/protobuf-java-2.5.0.jar
    ~/directory/target/docker/stage/opt/docker/lib/org.fusesource.leveldbjni.leveldbjni-all-1.7.jar
  from
    ~/.ivy2/maven-cache/org/fusesource/leveldbjni/leveldbjni-all/1.7/leveldbjni-all-1.7.jar
      ~/.ivy2/cache/org.fusesource.leveldbjni/leveldbjni-all/bundles/leveldbjni-all-1.7.jar
    at scala.sys.package$.error(package.scala:27)
    at sbt.Sync$.noDuplicateTargets(Sync.scala:67)
    at sbt.Sync$$anonfun$apply$1.apply(Sync.scala:25)
    at sbt.Sync$$anonfun$apply$1.apply(Sync.scala:22)
    at com.typesafe.sbt.packager.Stager$.stageFiles(Stager.scala:26)
    at com.typesafe.sbt.packager.Stager$.stage(Stager.scala:40)
    at com.typesafe.sbt.packager.docker.DockerPlugin$$anonfun$projectSettings$17.apply(DockerPlugin.scala:117)
    at com.typesafe.sbt.packager.docker.DockerPlugin$$anonfun$projectSettings$17.apply(DockerPlugin.scala:117)
    at scala.Function3$$anonfun$tupled$1.apply(Function3.scala:35)
    at scala.Function3$$anonfun$tupled$1.apply(Function3.scala:34)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
  [error] (docker:stage) Duplicate mappings:
  [error]   ~/directory/target/docker/stage/opt/docker/lib/org.scalaz.scalaz-core_2.11-7.1.0.jar
  [error] from
  [error]   ~/.ivy2/maven-cache/org/scalaz/scalaz-core_2.11/7.1.0/scalaz-core_2.11-7.1.0.jar
  [error]     ~/.ivy2/cache/org.scalaz/scalaz-core_2.11/bundles/scalaz-core_2.11-7.1.0.jar
  [error]   ~/directory/target/docker/stage/opt/docker/lib/com.typesafe.config-1.2.1.jar
  [error] from
  [error]   ~/.ivy2/maven-cache/com/typesafe/config/1.2.1/config-1.2.1.jar
  [error]     ~/.ivy2/cache/com.typesafe/config/bundles/config-1.2.1.jar
  [error]   ~/directory/target/docker/stage/opt/docker/lib/com.google.protobuf.protobuf-java-2.5.0.jar
  [error] from
  [error]   ~/.ivy2/maven-cache/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.jar
  [error]     ~/.ivy2/cache/com.google.protobuf/protobuf-java/bundles/protobuf-java-2.5.0.jar
  [error]   ~/directory/target/docker/stage/opt/docker/lib/org.fusesource.leveldbjni.leveldbjni-all-1.7.jar
  [error] from
  [error]   ~/.ivy2/maven-cache/org/fusesource/leveldbjni/leveldbjni-all/1.7/leveldbjni-all-1.7.jar
  [error]     ~/.ivy2/cache/org.fusesource.leveldbjni/leveldbjni-all/bundles/leveldbjni-all-1.7.jar

1 个答案:

答案 0 :(得分:2)

似乎是相对较新的SBT功能,this导致问题。

将此添加到您的构建中:

updateOptions := updateOptions.value.withCachedResolution(false)

为我解决了。