I have some amount of child maven modules in parent module. How can I get access from one module to resources of another and to have this solution stable in jar file ? I tried something like: (resource.txt - is situated in first module, and code is executing in second)
String pathToFirstModuleResource = ClassFromFirstModule.class.getClassLoader().getResource(resource.txt).getFile();
But it points me to ...firstmodule/target/classes/resource.txt
, so it works almost good, but returns not a resource folder, but target/classes
. Why it returns this targets folder, though should to return ...firstmodule/resources/resource.txt
?