Is it possible to make Scala (or Java called from Scala) check whether a resource is missing at compile time and throw a compile error if it’s missing?
I’m working on a large Java/Scala hybrid project with many developers and I’m providing a Scala component that kicks in near the end of the system run. So if my component throws a missing resource runtime error, it’s only discovered very late. I try to make sure that my resource is there so this doesn’t happen. But several times already, the head engineer decided to shift things around, my resources changed paths, I wasn’t aware so didn’t change my code, then the code died at my component because of the missing resource. We’re working on more centralized resource control, but in the meantime, would it be possible to make Scala throw a compile error over a missing resource? Mostly curiosity, but might implement if it turns out simple enough.
ETA: There’s questions about build tools. It’s not straightforward because everyone is using their own environment. Some are using eclipse, some netbeans, I’m using emacs+sbt. So even if I insert a check for sbt, it won’t matter to other people who are using eclipse.
In 2.10, it is definitely possible with help of a macro and string interpolation: