I have a file in my src/main/resources folder in a multi-module Gradle project:
modulename/src/main/resources/file
If I try to load it from my program it works just fine:
new File("modulename/src/main/resources/file").exists()
// true
but when I try to load the same file from a test, it fails:
java.io.FileNotFoundException: modulename/src/main/resources/file (The system cannot find the path specified)
I fiddled around with this and it turned out that it only finds this file if I remove the module name from the path when I'm trying to load the file in a test:
new File("modulename/src/main/resources/file").exists()
// false
new File("src/main/resources/file").exists()
// true
Why is this the case and how can I fix this? My problem is that I have an enum which contains hard-coded paths for some resources and I can't change it from my test.
There is a caveat: I can't use the getResourceAsStream method to alleviate this problem for some internal reason.
Aucun commentaire:
Enregistrer un commentaire