sbt组装失败,因为找到了不同的文件内容

时间:2019-04-23 07:12:27

标签: scala sbt gitlab sbt-assembly

我正在尝试在GitLab中构建一个项目。 在gitlab-ci.yml中,我运行了sbt程序集并遇到了令人讨厌的异常。

[error] (soda/*:assembly) deduplicate: different file contents found in the following:
[error] /root/.ivy2/cache/io.netty/netty-buffer/jars/netty-buffer-4.0.42.Final.jar:META-INF/io.netty.versions.properties
[error] /root/.ivy2/cache/io.netty/netty-common/jars/netty-common-4.0.42.Final.jar:META-INF/io.netty.versions.properties
[error] /root/.ivy2/cache/io.netty/netty-codec-http/jars/netty-codec-http-4.0.42.Final.jar:META-INF/io.netty.versions.properties
[error] /root/.ivy2/cache/io.netty/netty-codec/jars/netty-codec-4.0.42.Final.jar:META-INF/io.netty.versions.properties
[error] /root/.ivy2/cache/io.netty/netty-transport/jars/netty-transport-4.0.42.Final.jar:META-INF/io.netty.versions.properties
[error] /root/.ivy2/cache/io.netty/netty-handler/jars/netty-handler-4.0.42.Final.jar:META-INF/io.netty.versions.properties
[error] /root/.ivy2/cache/io.netty/netty-transport-native-epoll/jars/netty-transport-native-epoll-4.0.42.Final-linux-x86_64.jar:META-INF/io.netty.versions.properties

我尝试按照sbt-assembly: deduplication found error中的说明进行操作,并且似乎已经制定了MergeStrategy,但是仍然存在例外情况:

[info] Merging files...
[warn] Merging 'NOTICE' with strategy 'rename'
[warn] Merging 'README' with strategy 'rename'
[warn] Merging 'META-INF/NOTICE.txt' with strategy 'rename'
[warn] Merging 'license/NOTICE' with strategy 'rename'
[warn] Merging 'META-INF/NOTICE' with strategy 'rename'
[warn] Merging 'org/xerial/snappy/native/README' with strategy 'rename'
[warn] Merging 'license' with strategy 'rename'
[warn] Merging 'license/LICENSE' with strategy 'rename'
[warn] Merging 'META-INF/license' with strategy 'rename'
[warn] Merging 'META-INF/LICENSE.txt' with strategy 'rename'
[warn] Merging 'LICENSE.txt' with strategy 'rename'
[warn] Merging 'META-INF/LICENSE' with strategy 'rename'
[warn] Merging 'LICENSE' with strategy 'rename'
[warn] Merging 'META-INF/DEPENDENCIES' with strategy 'discard'
[warn] Merging 'META-INF/INDEX.LIST' with strategy 'discard'
[warn] Merging 'META-INF/MANIFEST.MF' with strategy 'discard'

我也尝试更改sbt版本,但问题仍然存在。

任何有关如何解决此问题的帮助都将非常有用。

3 个答案:

答案 0 :(得分:0)

无处不在找不到任何解决方案。 检查以下解决方案是否对您有用,但对我不起作用: https://github.com/sbt/sbt-assembly/issues/297

答案 1 :(得分:0)

我曾经在一些Java软件包和log4j中遇到类似的问题,我所做的是创建一个自定义合并策略,在该策略中,我只选择了第一个匹配项。也许您可以修改该代码以使其适合您:

assemblyMergeStrategy in assembly := {
//  case PathList("javax", "servlet", xs @ _*)         => MergeStrategy.first
  case PathList("org", "apache", "commons", xs @ _*)        =>
 //   println(s"$xs")
    MergeStrategy.first
  case PathList(ps @ _*) if ps.last endsWith ".html" => MergeStrategy.first
  case "application.conf"                            => MergeStrategy.concat
  case "log4j.properties"                            => MergeStrategy.first
  case "unwanted.txt"                                => MergeStrategy.discard
  case x =>
    val oldStrategy = (assemblyMergeStrategy in assembly).value
    oldStrategy(x)
}

也许您要更改

 case PathList("org", "apache", "commons", xs @ _*)        =>
 //   println(s"$xs")
    MergeStrategy.first

解决有问题的软件包(netty):

 case PathList("io", "netty", xs @ _*)        =>
 //   println(s"$xs")
    MergeStrategy.first

答案 2 :(得分:0)

最终,我找到了解决此问题的方法。 由于它是一个play项目,因此我可以使用激活器将其包装并创建一个包。 我使用以下代码来创建程序包:      wget https://downloads.typesafe.com/typesafe-activator/1.3.7/typesafe-activator-1.3.7.zip &&解压缩typesafe-activator-1.3.7.zip 1> / dev / null      activator-dist-1.3.7 / activator -Dsbt.log.noformat = true -java-home /usr/lib/jvm/java-1.8-openjdk程序包clean compile test dist