Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fix missing conf files when using shadowJar and Scala dependencies?

Writing this for users who have future issues like me. Libraries that are built on the Typesafe config typically use their own reference.conf files and refer to certain configuration keys. When building a fat JAR using the Gradle shadowJAR plugin, these files aren't included.

Dependencies like Spray and Akka throw errors when the fat JAR attempts to run. Errors look like:

Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'spray'
Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka'

How to fix this? Check the answer below.

like image 739
crockpotveggies Avatar asked Dec 17 '15 03:12

crockpotveggies


2 Answers

Simply:

  shadowJar {
    append('reference.conf')
  }

See Controlling JAR Content Merging

like image 33
rdesgroppes Avatar answered Sep 18 '22 19:09

rdesgroppes


The resulting fix was to add the following to the build.gradle file:

shadowJar {
  transform(com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer) {
    resource = 'reference.conf'
  }
}

Solution was found here:http://www.sureshpw.com/2015/10/building-akka-bundle-with-all.html

like image 60
crockpotveggies Avatar answered Sep 17 '22 19:09

crockpotveggies