rocksdb
rocksdb copied to clipboard
Add automatic module name to the rocksdbjni jar artifact
Currently, jar artifacts of rocksdbjni, published in maven repositories, lack any information about JPMS modules, introduced in Java 9. This makes in challenging to use the rocksdbjni jar as a dependency for your module in module-info.java, like in the following example:
module my.module {
requires rocksdbjni; // Automatic module name, derived from the file name.
}
Although java itself provides compatibility with such libraries, it is not recommended. Third-party build tools are more strict.
Maven, for example, shows a following warning: Required filename-based automodules detected. Please don't publish this project to a public artifact repository!.
Gradle won't be able to build the project with this dependency at all. According to the documentation there could be two types of jar modules:
- There's a
module-info.classin the jar. This is explicit module, created with Java 9+ compiler. - There's an
Automatic-Module-Nameattribute inside of theMETA-INF/MANIFEST.MFfile in thejarartifact.
If jar file meets one of these requirements, it will be recognized as a module and passed to --module-path compiler argument. Otherwise, it will be passed into a -classpath argument. In the example above, the latter happens, and build fails with the following message:
> Task :my.module:compileJava FAILED
<path>/module-info.java:21: error: module not found: rocksdbjni
requires rocksdbjni;
^
1 error
In this PR, I solve this issue by introducing an explicit automatic module name.
@ibessonov The JAR files are not built from the pom.xml.template, you will instead need to modify the Makefile and CMakeLists
@adamretter Thank you for the feedback, I will update the PR soon.