I'm using the sbt assembly plugin to create a JAR file and I have the following folder structure:
src
-main
-scala
-resources
-application.conf
Now, when I do
sbt clean assembly
I can see in the produced Jar file that the application.conf file is included. I have two questions:
Why is the inluded application.conf not inside the resources folder in the final Jar, but rather it is on the top level as shown below (the contents of the Jar)
drwxr-xr-x 3 joe staff 102B May 16 21:03 com/
-rw-r--r-- 1 joe staff 187B Mar 4 2016 library.properties
drwxr-xr-x 3 joe staff 102B May 16 21:03 typesafe/
How can I load this application.conf by setting a System.property? For example., I want to be able to load the application.conf by setting a System property like:
System.setProperty("config.file", "application.default.conf")
With this I could control from outside (while running the jar file), which config file to use. When I tried this, I got a NulPointerException:
val someConfigFile = Option(System.getProperty("config.file"))
ConfigFactory.parseURL(getClass.getResource(someConfigFile.get)) // NullPointerException happens here...
The answer to your first question is that the resources folder is like a src folder and so the content is copied, not the folder itself.