sbt / sbt-assembly

Deploy über-JARs. Restart processes. (port of codahale/assembly-sbt)
MIT License
1.95k stars 225 forks source link

Filenames ending in `.conf` should be concatenated out-of-the-box #406

Open marcospereira opened 4 years ago

marcospereira commented 4 years ago

Problem

Currently, sbt-assembly fails if the dependency jar artifact cointains other configuration files (in the sense of Lightbend Config) besides reference.conf, reference-overrides.conf, and application.conf. For example, if a version.conf file is present, like the one in Akka and possibly others.

The failure will be similar to:

[error] 1 error was encountered during merge
[error] stack trace is suppressed; run last assembly for the full output
[error] (assembly) deduplicate: different file contents found in the following:
[error] /Users/marcospereira/.ivy2/local/com.typesafe.akka/akka-stream-kafka_2.13/2.0.4+12-31cf63dd/jars/akka-stream-kafka_2.13.jar:version.conf
[error] /Users/marcospereira/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/typesafe/akka/akka-actor_2.13/2.5.30/akka-actor_2.13-2.5.30.jar:version.conf

Expectation

.conf files such Akka's version.conf should be considered configuration files, and therefore concatenated by default.

A fix should involve changing the code here: https://github.com/sbt/sbt-assembly/blob/4840a2f972598c65a2ae1106bf2393de0b392ad0/src/main/scala/sbtassembly/Assembly.scala#L309-L313

Notes

Lighbend Config supports application.properties, and application.json besides application.conf, although those are arguably less popular. Anyhow, maybe sbt-assembly should also handle them out-of-the-box.

viniru commented 2 years ago

Hi @marcospereira Have you considered a case where multiple dependencies have application.conf with the same keys mapped to different values ? I cannot find anywhere how "concat" would handle such a scenario. Is there anyway I could customise to pick the right key value pair or if both the key-value pairs are needed by different dependencies, would shading help here ? Please help