0

I am currently using sbt-assembly to make my Scala project into a jar.

In this program I have multiple config files:

\root    
    aws.properties
    \src
        \resource
            application.conf    

There is no problem when program running with sbt or an IDE.

However when I make it as a jar, the application can't find the config files, so that something can't start up.

Is there a way to tell sbt-assembly where the file is?

Update

Here is how I tried to get access to config files:

val configPath: String = ConfigFactory.load.getConfig("aws").getString("configFile")
val regionName = ConfigFactory.load.getConfig("aws").getString("region")
val credentialFile: File = new File(credentialFilePath)
val credentials: AWSCredentials = new PropertiesCredentials(credentialFile)
Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
Chris Kong
  • 389
  • 1
  • 4
  • 18

2 Answers2

0

When you assemble your application, unpack it to see its content. Any discrepancies in the locations of the files could likely be resolved with assembledMappings.

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
0

I had the same problem. I had my AwsCredentials.properties file in src/main/java. This worked fine when I ran sbt-assembly from my eclipse project folder.

However, when I ran sbt-assembly on another machine with no eclipse, it wasn't putting AwsCredentials.properties into the fat jar.

So I moved AwsCredentials.properties into src/main/resources, and that fixed it.

thund
  • 1,842
  • 2
  • 21
  • 31