Using Finatra with SBT, where are the files searched for?

54 views Asked by At

Where does Finatra search for the files? When I write

response.ok.file(...)

in which folder should the files be placed to be found?

In the docs it says the "classpath root" which is nowhere to be found (as it doesn't exist, strictly speaking).

2

There are 2 answers

1
LowFieldTheory On BEST ANSWER

The files taken from the resources folder will be copied under:

target/scala-2.12/classes

for Scala 2.12, BUT for files which will be created during runtime this path won't be available, i.e. the process will find only the files created before doing sbt run. This is true for both root projects and subprojects (it depends on where the run was executed).

If you need to have files loaded at all times, you need to set the flag -local.doc.root .

0
AudioBubble On

It will search inside the resources folder

src/main/resources

In the example below I have a web folder inside the resources

  get("/:*") { request: Request =>
    response.ok.fileOrIndex(
      s"web/${request.params("*")}",
      "web/index.html")
  }

If you are using intellijIdea you have to make sure you all the resources types defined in the configuration:

compiler->resource patters

Otherwise when compiling it won't copy it over to the output folder