1

我正在尝试组装我的 scala 项目并且无法摆脱一些重复数据删除错误这是有问题的输出:

> [error] 2 errors were encountered during merge [error] stack trace is
> suppressed; run 'last
> ProjectRef(uri("https://hyehezkel@fs-bitbucket.fsd.forescout.com/scm/~hyehezkel/classification_common.git#test_branch"),
> "global") / assembly' for the full output [error]
> (ProjectRef(uri("https://hyehezkel@fs-bitbucket.fsd.forescout.com/scm/~hyehezkel/classification_common.git#test_branch"),
> "global") / assembly) deduplicate: different file contents found in
> the following: [error]
> C:\Users\hyehezkel\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\io\netty\netty-buffer\4.1.42.Final\netty-buffer-4.1.42.Final.jar:META-INF/io.netty.versions.properties
> [error]
> C:\Users\hyehezkel\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\io\netty\netty-codec\4.1.42.Final\netty-codec-4.1.42.Final.jar:META-INF/io.netty.versions.properties
> [error]
> C:\Users\hyehezkel\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\io\netty\netty-common\4.1.42.Final\netty-common-4.1.42.Final.jar:META-INF/io.netty.versions.properties
> [error]
> C:\Users\hyehezkel\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\io\netty\netty-handler\4.1.42.Final\netty-handler-4.1.42.Final.jar:META-INF/io.netty.versions.properties
> [error]
> C:\Users\hyehezkel\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\io\netty\netty-resolver\4.1.42.Final\netty-resolver-4.1.42.Final.jar:META-INF/io.netty.versions.properties
> [error]
> C:\Users\hyehezkel\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\io\netty\netty-transport-native-epoll\4.1.42.Final\netty-transport-native-epoll-4.1.42.Final.jar:META-INF/io.netty.versions.properties
> [error]
> C:\Users\hyehezkel\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\io\netty\netty-transport-native-unix-common\4.1.42.Final\netty-transport-native-unix-common-4.1.42.Final.jar:META-INF/io.netty.versions.properties
> [error]
> C:\Users\hyehezkel\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\io\netty\netty-transport\4.1.42.Final\netty-transport-4.1.42.Final.jar:META-INF/io.netty.versions.properties
> [error] deduplicate: different file contents found in the following:
> [error]
> C:\Users\hyehezkel\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\com\fasterxml\jackson\core\jackson-annotations\2.10.1\jackson-annotations-2.10.1.jar:module-info.class
> [error]
> C:\Users\hyehezkel\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\com\fasterxml\jackson\core\jackson-core\2.10.1\jackson-core-2.10.1.jar:module-info.class
> [error]
> C:\Users\hyehezkel\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\com\fasterxml\jackson\core\jackson-databind\2.10.1\jackson-databind-2.10.1.jar:module-info.class
> [error]
> C:\Users\hyehezkel\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\com\fasterxml\jackson\dataformat\jackson-dataformat-csv\2.10.0\jackson-dataformat-csv-2.10.0.jar:module-info.class

我已经阅读了以下文章,但没有设法解决它: https ://index.scala-lang.org/sbt/sbt-assembly/sbt-assembly/0.14.5?target=_2.12_1.0

这是我的 plugins.sbt

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")

这是我的 build.st

import sbt.Keys.{dependencyOverrides, libraryDependencies, mappings}
import sbtassembly.AssemblyPlugin.assemblySettings._

name := "classification_endpoint_discovery"
version := "0.1"
organization in ThisBuild := "com.forescout"
scalaVersion in ThisBuild := "2.13.1"
updateOptions := updateOptions.value.withCachedResolution(true)
//classpathTypes += "maven-plugin"
exportJars := true
logLevel := Level.Info
logLevel in assembly := Level.Debug
lazy val commonProject = RootProject(uri("https://hyehezkel@fs-bitbucket.fsd.forescout.com/scm/~hyehezkel/classification_common.git#test_branch"))

lazy val global = project
  .in(file("."))
  .settings(settings)
  .enablePlugins(AssemblyPlugin)
//  .disablePlugins(AssemblyPlugin)
  .aggregate(
    commonProject,
    `endpoint-discovery`
  )

lazy val `endpoint-discovery` = project
  .settings(
    name := "endpoint-discovery",
    settings,
    assemblySettings,
    assemblyJarName in assembly := "endpoint-discovery.jar",
    assemblyJarName in assemblyPackageDependency := "endpoint-discovery-dep.jar",
    libraryDependencies += dependencies.postgresql,
    libraryDependencies += "com.lihaoyi" %% "ujson" % "0.7.5",
    libraryDependencies += "com.lihaoyi" %% "requests" % "0.2.0",
    libraryDependencies += dependencies.`deepLearning4j-core`,
    libraryDependencies += dependencies.`deeplearning4j-nn`,
    libraryDependencies += dependencies.`nd4j-native-platform`,
    excludeDependencies += "commons-logging" % "commons-logging"
//    dependencyOverrides += "org.slf4j" % "slf4j-api" % "1.7.5",
//    dependencyOverrides += "org.slf4j" % "slf4j-simple" % "1.7.5",
  )
  .dependsOn(commonProject)
  .enablePlugins(AssemblyPlugin)
lazy val dependencies =
  new {
    val deepLearning4jV         = "1.0.0-beta4"
    val postgresqlV             = "9.1-901.jdbc4"

    val `deepLearning4j-core`    = "org.deeplearning4j"         % "deeplearning4j-core"      % deepLearning4jV
    val `deeplearning4j-nn`      = "org.deeplearning4j"         % "deeplearning4j-nn"        % deepLearning4jV
    val `nd4j-native-platform`   = "org.nd4j"                   % "nd4j-native-platform"     % deepLearning4jV
    val postgresql               = "postgresql"                 % "postgresql"               % postgresqlV
  }

// SETTINGS
lazy val settings =
  commonSettings

lazy val compilerOptions = Seq(
  "-unchecked",
  "-feature",
  "-language:existentials",
  "-language:higherKinds",
  "-language:implicitConversions",
  "-language:postfixOps",
  "-deprecation",
  "-encoding",
  "utf8"
)

lazy val commonSettings = Seq(
  scalacOptions ++= compilerOptions
)

lazy val assemblySettings = Seq(
  assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false, includeDependency = false),
  assemblyMergeStrategy in assembly := {
    case PathList("META-INF", "io.netty.versions.properties", xs @ _*) => MergeStrategy.singleOrError
    case "module-info.class"                         => MergeStrategy.singleOrError

    case PathList("org", "xmlpull", xs @ _*)         => MergeStrategy.discard
    case PathList("org", "nd4j", xs @ _*)            => MergeStrategy.first
    case PathList("org", "bytedeco", xs @ _*)        => MergeStrategy.first
    case PathList("org.bytedeco", xs @ _*)           => MergeStrategy.first
    case PathList("META-INF", xs @ _*)               => MergeStrategy.discard
    case "XmlPullParser.class"                       => MergeStrategy.discard
    case "Nd4jBase64.class"                          => MergeStrategy.discard
    case "XmlPullParserException.class"              => MergeStrategy.discard
//    case n if n.startsWith("rootdoc.txt") => MergeStrategy.discard
//    case n if n.startsWith("readme.html") => MergeStrategy.discard
//    case n if n.startsWith("readme.txt") => MergeStrategy.discard
    case n if n.startsWith("library.properties") => MergeStrategy.discard
    case n if n.startsWith("license.html") => MergeStrategy.discard
    case n if n.startsWith("about.html") => MergeStrategy.discard
//    case _ => MergeStrategy.first
      case x =>
        val oldStrategy = (assemblyMergeStrategy in assembly).value
        oldStrategy(x)
  }
)

我尝试了许多合并策略,但没有任何效果我在这里缺少什么?有什么建议吗?

4

1 回答 1

1
  1. 为了META-INF/io.netty.versions.properties

    你有:

    case PathList("META-INF", "io.netty.versions.properties", xs @ _*) => MergeStrategy.singleOrError
    

    这表示如果有超过 1 个具有此名称的文件,它将出错。

    尝试MergeStrategy.first使用这些文件

  2. module-info.class

    这些文件仅与 Java 9 模块系统相关。通常,您可以丢弃它们:

    case "module-info.class"                       => MergeStrategy.discard
    
于 2020-05-25T13:21:04.003 回答