-
Notifications
You must be signed in to change notification settings - Fork 387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate version information when publishing artifacts #1188
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with one question below.
|
||
val settings: Seq[Setting[_]] = inConfig(Compile)( | ||
Seq( | ||
resourceGenerators += generateVersion(resourceManaged, _ / "version.conf", """|akka.kafka.version = "%s" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the version.conf
file collide with others in a fat-jar scenario?
I guess those could be merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If multiple artifacts contain version.conf
files, users need to configure a merge strategy when using sbt-assembly, or they will get an error* like this:
[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
But since we are using a distinct key for alpakka-kafka version, it is safe to concat the files, as you guessed.
* I'm not sure why sbt-assembly is not handling all filenames ending in .conf
as configuration files. Maybe it is worth to send a PR there too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, merging *.conf
files seems reasonable to me.
An alternative for now would be to create a file named akka-kafa-version.conf
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum, "for now" implying that it is going to change in the future, right? If so, I would not bother to have another name, and then move to version.conf
later. Users should be able to configure what to do pretty easily, so I don't see why to have extra steps here. But also, I don't have a strong opinion on that. My only concern is to handle multiple version files in Cinnamon in the future.
Finally, I created a new issue in sbt-assembly: sbt/sbt-assembly#406. If they decide it make sense to support all .conf
files out-of-the-box, I will submit a PR there, and users would only need to update sbt-assembly then.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hi All. I am not sure I wrote to the right place but this commit is not working in shaded jar. We have an application that we use akka and akka-streams together and when we try to run our app We got following exception since we have only 'akka.kafka.version' in our version.conf instead of 'akka.version'.
|
It's not clear from the stack trace that this is related to Alpakka Kafka itself since the issue is resolving |
Yes. I am creating fat jar and I am following the instructions in packaging doc. I opened the jar and saw we do not have 'akka.version' in version.conf. When I downgraded to 2.0.4 I have 'akka.version' and everything works fine. |
How are you packaging the fat jar? Is it using sbt-assembly? If that is the case, you have to configure it to use |
I am using gradle. I will have a look at MergeStrategy.concat. Thank you. |
Hi all, I encountered same problem of 'akka.version' as @gurgec with alpakka-kafka 2.0.5. Everything works well when I downgraded to 2.0.4. Resolved by merging https://doc.akka.io/docs/akka/current/additional/packaging.html |
As described above: You need to configure your fat jar tooling to merge the |
Currently, the only way to get version information from alpakka-kafka artifacts is by reading its
MANIFEST.MF
file, which may be fragile when sbt-assembly or other fatjar packagers are used: the manifest can be lost, overridden by another one, or multiple artifacts may be usingImplementation-Version
key.To overcome this problem, Akka, Play, and Lagom all package a version class containing such information. Therefore, no matter if the application using them is building a fatjar or not, the version information is consistently accessible.
This pull request brings Akka solution and creates both
akka.kafka.Version
class as well as aversion.conf
with a key that is less prone to conflict with another artifact.