I'm having difficulty trying to load a resource file from an external module's resource folder. I am using IntelliJ and our project is built using Maven.
The original code, prior to using modules was as such:
getClass().getResourceAsStream(rulesFile)
This now results in a null result.
The structure of the modules is as such:
client
- java
- org.example.client
- Controller.java
data
- java
- ...
- resources
- org.example.data.files
- rulesFile
In module client:
getClass().getResourceAsStream(rulesFile) does not work.
However, if I try and do ModuleLayer.boot().findModule("data").get().getResourceAsStream(rulesFile), then it works fine.
My question is, is it possible to make the rulesFile visible to the Controller.java inside the client module so that a normal class loader can be used? I would like to avoid having to explicitly specify the module name it is coming from as similar code to load files from the data module is used elsewhere.
What options do I have to avoid having to explicitly giving the module name?
I have tried adding the following to the data module file, with no success:
opens org.example.data.files to client
Thanks for the help!