I am working on an application that uses sbt-native-packager with the akka_application
archetype.
I have a directory structure that looks like:
src/
main/
resources/
application.conf
somePrivateKey.p12
Within my code, I have a method to return a file handle to the p12 file
def getSomePrivateKey: java.io.File = {
val cl = this.getClass.getClassLoader
val fileUrl = cl.getResource("somePrivateKey.p12")
new java.io.File(fileUrl.getFile())
}
When I use this from the command line via sbt console
, it works perfectly. I can easily work with the file, as expected.
However, when I run sbt stage
and then run the executable it creates, I get a FileNotFoundException
when trying to open the file.
How can I tell sbt-native-packager to copy all of the files within resources onto the created JAR's ClassPath? I've read and re-read the sbt-native-packager documentation, tried adding the resource to Universal
, and it still happens every time. Is there another way I should be approaching this?