rocksdb icon indicating copy to clipboard operation
rocksdb copied to clipboard

Add automatic module name to the rocksdbjni jar artifact

Open ibessonov opened this issue 2 years ago • 2 comments

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.class in the jar. This is explicit module, created with Java 9+ compiler.
  • There's an Automatic-Module-Name attribute inside of the META-INF/MANIFEST.MF file in the jar artifact.

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 avatar Sep 24 '23 10:09 ibessonov

@ibessonov The JAR files are not built from the pom.xml.template, you will instead need to modify the Makefile and CMakeLists

adamretter avatar Feb 13 '24 16:02 adamretter

@adamretter Thank you for the feedback, I will update the PR soon.

ibessonov avatar Feb 13 '24 17:02 ibessonov