简体   繁体   中英

Supplying resources outside JAR

A lot of manuals say that canonical way to store resources is under resources folder in a project. The problem is that after assembling a project all of the resources are getting inside JAR. In my case resources are SQL scripts and I would like avoid assembling a new JAR if any SQL script changes. So I wish to supply resources in addition to JAR file. It will be tricky to access those files using typical methods for resources so the only way I can think of is considering them just as regular files in the file system (not resources as such).

Is is the right way to move forward? What are the possible alternative solutions.

It's possible to use SQL scripts as resources and ship them in a separate folder instead of JAR but probably it does not make sense. Since in such case it's much more reasonable to siply use files in the file system.

If, however, someone wants to do this trick then you need to

  1. Add that folder into CP so that you can access files as resources

https://www.scala-sbt.org/1.x/docs/Classpaths.html

https://docs.huihoo.com/sbt/0.12.4/Detailed-Topics/Classpaths.html

  1. Exclude resources from JAR

sbt-assembly: How do I exclude the configuration files in src/main/resources

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM