playframework / play-mailer

Play mailer plugin
Apache License 2.0
250 stars 74 forks source link

SBT assembly #190

Closed mmesar closed 1 year ago

mmesar commented 4 years ago

Hi, im using scala 2.13.1, play framework version 2.8.1, sbt version 1.3.4

have dependencies:

guice
javaWs,
"com.lightbend.akka" %% "akka-stream-alpakka-json-streaming" % "2.0.1"
"com.typesafe.play" %% "play-mailer" % "8.0.1"
"com.typesafe.play" %% "play-mailer-guice" % "8.0.1"

and I am using sbt assembly plugin ("com.eed3si9n" % "sbt-assembly" % "0.14.5") to create nice fat single jar with this configuration

assemblyMergeStrategy in assembly := {
  case manifest if manifest.contains("MANIFEST.MF") =>
    // We don't need manifest files since sbt-assembly will create
    // one with the given settings
    MergeStrategy.discard
  case referenceOverrides if referenceOverrides.contains("reference-overrides.conf") =>
    // Keep the content for all reference-overrides.conf files
    MergeStrategy.concat
  case "module-info.class" => MergeStrategy.discard
  case x =>
    // For all the other files, use the default sbt-assembly merge strategy
    val oldStrategy = (assemblyMergeStrategy in assembly).value
    oldStrategy(x)
}

test in assembly := {}

When i try to run sbt assembly command I get this deduplicate

i removed play-mailer and deduplicate errors don't show anymore... so i guess problem is in play-mailer.

I am not so skilled in scala and sbt environment, build flows etc. Would appreciate advice how to tackle this or in what direction should i continue to search and learn.

raboof commented 4 years ago

i guess problem is in play-mailer

Well, the problem is that the resources in different dependencies overlap and aren't identical.

In the case of mailcap.default and mimetypes.default, I suspect the files are actually really similar and you can configure the assemblyMergeStrategy to just pick one.

In case of the overlap between jakarta.activation-api and javax.activation, I guess it would be best to pick one and exclude the other dependency from your dependency tree?

mmesar commented 4 years ago

I succeed in making jar with following code added in build.sbt

excludeDependencies ++= Seq(
  ExclusionRule("javax.activation")
)

Again following question may not be appropriate to this place. Again would be grateful with advice where to look and ask next. I am curious what exactly is happening here so I could understand the situation better. This is my take on it. At some point while 'building' jar, 'engine' will download all dependencies from all 'components' that are used in the project. At some other point while injecting the objects 'engine' will stumble upon an object, that has to be injected, that is typed as an interface. Next, the engine will search in, I assume, classpath for a class that implement that interface but will find multiple classes that implement given interface and that's where a collision occurs.

Am I on the right path of understanding this or? Thx

mkurz commented 1 year ago

This is not play-mailer specific, you should ask further questions in https://github.com/sbt/sbt-assembly