Building a runnable scala jar file with akka library as dependency


i created a small scala application which uses akka ( as a dependency. Now when i try to create a fat jar to be able to execute that standalone i get a problem with akka. My jar task is very basic: jar {

from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }

manifest { attributes ‘Main-Class’: ‘de.sveri.scala.scspider.Main’ } } and it does what it should besides one thing. Akka uses a configuration file which is merged from different libraries (see the second warning “When using JarJar, OneJar, Assembly or any jar-bundler” on this page: while trying to create the jar.

The jar task just adds two different versions of the same config file into the jar, which is not sufficient enough to make it work. I read that you somehow have to merge them and it works if i do manually. However, i dont want to use such a great build tool and then still have to do some manual work afterwards. Is there a way to solve that issue? I read that there are plugins for maven and sbt which are able to merge that file, however, i dont want to use them as i like the simplicity of gradle very much (See this post for instance:

Best Regards, Sven

I just tried it as a sbt build with the plugin. The jar that is created works and what is does is simply add the contents of reference.conf2 to reference.conf and name it reference.conf.

Isnt there a way to accomplish something like this with gradle?

Best Regards, Sven

I recommend to use the gradle-one-jar plugin. Such a solution is safer and less effort than merging Jar entries.

Thank you very much Peter,

I was only trying the fatjar plugin ( which did not do it very succesfully. However, the gradle-one-jar plugin works great.

Best Regards, Sven