[update: sbt-assembly knows about reference.conf since 0.8.0, see the following post]
One of the things which changed in Akka 2.0 was the new configuration system, which is based upon the assumption that all used settings are defined in resources named “/reference.conf” and found on the classpath. This composes nicely, as then different libraries can coexist in the same project and the configuration systemjust works. One situation where this breaks, however, is when using fat jars for deployment. The problem usually shows up as
ConfigException$Missing: No configuration setting found for key: ‘akka.version’
and the cause is that during packaging of the fat jar only one of the many “reference.conf” files was copied instead of merging them all.
There was a discussion showing a solution when using proGuard, and I thought something similar should be possible using sbt-assembly. Eugene was so nice to add a hook which allows this to work, based on this ticket, so here it goes.
The following of course assumes that the sbt-assembly plugin has been installed in version 0.7.4, for which the following addition is needed:
Then the code to make SBT do the right thing is so little that it does not warrant its own plugin (it only looks long because this blog’s style is like literally writing on the margins of a newpaper):
Making the location of the merged “reference.conf” configurable or merging other things is left as an exercise to the reader.
As a bonus, this adds a “merge-reference” task which you can invoke to perform the merge and show the location:
> show merge-reference