TheRandomLabs / CurseAPI

A Java library for handling interactions with CurseForge.
MIT License
30 stars 3 forks source link

Java 9+ module naming #19

Closed Rakambda closed 4 years ago

Rakambda commented 4 years ago

I have troubles trying to import this library with Gradle. It downloads it fine and is added to the dependencies but can't use it in code.

After some tries it seems to come from the name of the jar file that is downloaded (something like CurseAPI-<commit hash>). Java 9+ may have some trouble to give it an automatic module name because of the hash (as it may contains letters) and thus make it impossible to require it.

If the name matches the regular expression "-(\d+(\.|$))" then the module name will be derived from the subsequence preceding the hyphen of the first occurrence.

https://docs.oracle.com/javase/9/docs/api/java/lang/module/ModuleFinder.html#of-java.nio.file.Path...-

So I wonder if there is a way (and if you want) to make JitPack use a more common version numbering or use the Automatic-Module-Name attribute in the manifest.


Edit: Using the master-SNAPSHOT version is fine but gives a module name of CurseAPI.master.SNAPSHOT which isn't really the best.

Actually running the app throws an exception because of the hash:

Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for D:\.gradle\caches\modules-2\files-2.1\com.github.TheRandomLabs\CurseAPI\5fff967415\36851ce3c218342bbdb85ffef6052c9e2b8f04fb\CurseAPI-5fff967415.jar
Caused by: java.lang.IllegalArgumentException: CurseAPI.5fff967415: Invalid module name: '5fff967415' is not a Java identifier
TheRandomLabs commented 4 years ago

Can you try now? I've set Automatic-Module-Name.

Rakambda commented 4 years ago

Tried with version 494b5fb9bf and it now have the module name com.therandomlabs.curseapi which is good. Thank you for the fast fix :)