javamavenjava-modulemoditect

Add a ResourceBundle service provider directive in a Java 13 module through moditect maven plugin


I got a Java project that I'm migrating from Java 8 to Java 13. This project uses ResourceBundles to enable language localisation.

In Java 8, I provided a custom ResourceBundle.Control to ResourceBundle.getBundle(baseName, control) but this doesn't work anymore in Java 9+. As I understand it, I must instead provide a custom ResourceBundleProvider interface, which I called UiProvider, and an implementation of this interface, UiProviderImpl, which must be used as a service.

To generate module descriptors, I'm using the moditect maven plugin. But it doesn't look like I can add a provides directive anywhere, only exports, opens and uses directives. Or am I missing anything? Here's an excerpt of my pom.xml with what I tried to configure. Can this be fixed?

<module>
        <moduleInfo>
                 <name>net.babelsoft.negatron</name>
                 <opens>net.babelsoft.negatron;</opens>
                 <uses>theme.language.spi.UiProvider</uses>
                 <provides>theme.language.spi.UiProvider with theme.language.spi.UiProviderImpl</provides>
        </moduleInfo>
 </module>

Solution

  • At the time I wrote my question, Moditect didn't support the provides directive within the moduleInfo tag. The only way was to use a moduleInfoSource tag, which forces the developper to directly write the actual content of module-info.java, not very satisfactory.

    After discussing with the author of Moditect, I submitted a pull request to add the support of the provides directive within the moduleInfo tag. It hasn't been merged to Moditect source code yet...