pemistahl / lingua

The most accurate natural language detection library for Java and the JVM, suitable for long and short text alike
Apache License 2.0
706 stars 63 forks source link

Fix Java module descriptor configuration #138

Closed Marcono1234 closed 2 years ago

Marcono1234 commented 2 years ago

Resolves hopefully #120

The workaround needed for the moditect-gradle-plugin issue is a bit brittle, but it seems to work for the current Lingua setup. Only the regular JAR is a Multi-Release JAR with module descriptor; the created -with-dependencies.jar is not a proper Multi-Release JAR, but that probably does not matter because I think you would normally not use JARs with dependencies as modules.

Also adds a test to verify that the modular JAR can be used by using the incubating Gradle Test Suite feature.

One issue with the moditect-gradle-plugin is that it does not seem to detect incorrect configuration of the module-info.java file, such as missing requires or exports of a non-existent package (though the test suite added by this PR would hopefully catch that). An alternative might be to perform regular compilation of the module-info.java file, similar to what is described in this StackOverflow question but that would require some adjustments to create a Multi-Release JAR.

pemistahl commented 2 years ago

Awesome work @Marcono1234. Thank you so much for your help. :) I don't have much knowledge about Java 9 modules yet so I'm very grateful for any help in this regard. 👍