我正在尝试在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版本,但问题仍然存在。
任何有关如何解决此问题的帮助都会很棒。
看着处处找不到任何解决方案。检查以下分辨率是否适合您,它对我不起作用:https://github.com/sbt/sbt-assembly/issues/297
我曾经遇到过类似的问题,有一些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
最终我找到了解决此问题的方法。由于它是一个游戏项目,我可以使用激活器将其包装起来并创建一个包。我使用以下代码来创建包:wget https://downloads.typesafe.com/typesafe-activator/1.3.7/typesafe-activator-1.3.7.zip && unzip 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包清理编译测试dist