Reputation: 671
I am trying to get used to writing modular Java applications using the modules-info.java. I am having trouble understanding how resource handling works now. From previous projects I am used having a "i18n/" directory within the resources, where I keep all my translation property files.
Project A
+- src/main/resources
+- i18n
+- projA_de.properties
+- projA_en.properties
Project B
+- src/main/resources
+- i18n
+- projB_de.properties
+- projB_en.properties
While this worked in Java 8 and still compiles with Java 11, I get the error
Package i18n in both module project.a and module project.b
I understand, that Java 11 much more expects the resources to be in the same directories as the class files. I guess this would work If I would rename the resource directories matching to the packages or any other unique way - but I don't like the clutter it produces.
Is there a workaround that would allow me to keep my resources as I am used to and still benefit from modularity?
Upvotes: 3
Views: 413
Reputation: 32028
I understand, that Java 11 much more expects the resources to be in the same directories as the class files
True, it does expect the resources to be at a similar directory path as of your classes in the packages to easily access them.
But, the modularity also expects that no two modules bring in the same package when resolved on the modulepath. Hence, as you already know the cleanest way to solve that is to rename your package structure of one of the modules
Or else, another workaround(not so good) would be to let these modules remain on the classpath and result to be categorized as the unnamed module.
Upvotes: 1