1

我尝试使用 Scala 和 EclipseLink JPA 为我的项目创建一个带有 sbt 和 sbt-assembly 插件的胖 jar,但组装命令失败,因为 eclipse.inf 文件会找到两次。

> assembly
[info] Including from cache: commonj.sdo-2.1.1.jar
[info] Including from cache: javax.persistence-2.1.0.jar
[info] Including from cache: scala-library.jar
[info] Including from cache: eclipselink-2.5.1.jar
[info] Run completed in 38 milliseconds.
[info] Checking every *.class/*.jar file's SHA-1.
[info] Merging files...
[warn] Merging 'org\eclipse\persistence\descriptors\copying' with strategy 'rename'
[warn] Merging 'META-INF\MANIFEST.MF' with strategy 'discard'
[trace] Stack trace suppressed: run last *:assembly for the full output.
[error] (*:assembly) deduplicate: different file contents found in the following:
[error] C:\Users\u987\WebApps\gr\lib_managed\jars\org.eclipse.persistence\javax.persistence\jav    ax.persistence-2.1.0.jar:META-INF/eclipse.inf 
[error] C:\Users\u987\WebApps\gr\lib_managed\jars\org.eclipse.persistence\commonj.sdo\commonj.sdo-2.1.1.jar:META-INF/eclipse.inf

我的 build.sbt 看起来像:

import AssemblyKeys._

name := "TelegramReceiver"

version := "0.1"

scalaVersion := "2.10.3"

retrieveManaged in ThisBuild := true

libraryDependencies ++= Seq(
  "org.scalatest" % "scalatest_2.10" % "2.0" % "test",
  "org.eclipse.persistence" % "eclipselink" % "2.5.1" 
)

我尝试使用 sbt 程序集插件中的 mergeStrategy 解决问题,但它不起作用。我使用 sbt 0.13.1。

提前感谢您的帮助!

4

1 回答 1

2

您可以将自定义合并策略添加到您的设置中,如下所示:

  mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
  {
    case PathList("eclipse.inf") => MergeStrategy.rename // use any of the available strategies like `first`
    case x => old(x)
  }}

有关更多详细信息,请参阅此文档

于 2014-02-18T18:40:37.463 回答