Reputation: 1633
I would like to generate scala classes based on some files. Placement of the files doesn't matter (it can be resources folder or files can be placed just near my scala source files).
How can I read them when scala macro is executed? (I use StaticAnnotation's inline def apply(defn: Any): Any method)
When I try to use resources, they can't be found (I suppose those resources can't be found because it's compile time and project is not compiled yet) I would like to read files placed right near my scala sources, but how can I get source file path when macro is executed?
Upvotes: 1
Views: 653
Reputation: 1384
your project dir
val projectDir = System.getProperty("user.dir")
now you can access source file
val file = new File(s"$projectDir/src/resources/<SOURCES FILE>")
Upvotes: 0