Multi modules: separate Java library from native libs#1387
Multi modules: separate Java library from native libs#1387
Conversation
|
@kkriske tagging you here for information. All the tests are green for GraalVM, but since the packaging has changed quite a bit i don't know if there's anything we would need to pay attention to in particular. |
|
@michael-o if you could have a look that would be great, this would address your request to get a JAR free of native libs. |
Checking... |
| <packaging>jar</packaging> | ||
|
|
||
| <name>SQLite JDBC</name> | ||
| <description>SQLite JDBC library without native libraries</description> |
There was a problem hiding this comment.
The artifact id is a contradition to the description, no? It says JNI, yet it does not contain any native libraries?
There was a problem hiding this comment.
JNI is about the code, not necessarily about the bundling of the native libraries compiled with the JNI wrapper. Open to better naming.
There was a problem hiding this comment.
What about: SQLite JDBC library with a JNI bridge?
You need to keep in mind that in the future one want to create an FFM version of this library for Java 21+ and the name wouldn't fit anymore. See what we are doing in Tomat to interact with OpenSSL: We have a JNI-based library and now an FFM-based implementation: https://tomcat.apache.org/presentations/2024-06-05-coceu-OpenSSL-and-FFM.pdf
There was a problem hiding this comment.
In case there is a FFM implementation, we would split the sqlite-jdbc-jni:
- we would add a new artifact that would contain the JDBC code and an interface for native access, maybe something like
sqlite-jdbc-api(inspired bysqlf4j-api - the JNI code would remain in
sqlite-jdbc-jni - we would add another implementation
sqlite-jdbc-ffm
If you have better artifact names to propose please do, naming is always hard !
There was a problem hiding this comment.
This sounds resonable and why not do it now, I mean the split? No need to create the FFM module now, can be done later.
I am not very familiar with them, i read about it from the Gradle blog posts, but it seems like it's confusing to use. I don't see the upside. Would you have more to share on that and how it would help ?
That is for Maven aggregators, not for jar aggregators. The library aggregator for windows for example is just a jar with no code, just deps. |
No, consider that you have one main artifact and multiple side artifacts. javadoc and sources are two of them. One could create the JAR with Maven assembly plugin and attach them. Example: org.sonarsource.scanner.cli:sonar-scanner-cli:5.0.2.4997
No, that is wrong. These are classical POM dependencies which the sole purpose to aggregate other dependencies, see: This module must be a |
|
@michael-o thanks for the feedback, this is really appreciated. Maven is not my area of expertise.
You are right, i got confused with the Maven aggregators.
I read up on that yesterday, indeed we could keep a single project, and use the Maven Jar Plugin to build different classifier jars. However here are the shortcomings i see with this approach:
My understanding may be wrong though, as i am not super familiar with Maven classifiers. Would be happy to hear about the pros/cons of both approaches. |
Never mind, i figured out i needed to add |
|
but now GraalVM tests fails because of the POM type dependency used for tests T_T |
|
for the sake of testing i created another PR that uses classifier jars: #1388 |
I'll get back to this next week with more guidance. |
As long as the resource locations of the actual libs stays the same, it doesn't matter they are in separate artifacts. I don't see any conceptual issues with this towards native-image. |
Another approach is proposed here: #1388
Motivation
This addresses #1273
Moving the single project build into multi-modules, the goal being to separate the native libraries into separate jars, which can then be selectively added to a project depending on the needs.
Implementation
The native libraries have been moved each to a dedicated project/artifact, with the following file naming:
sqlite-jdbc-jni-libs-${OS}-${ARCH}In addition, some aggregation projects have been added:
sqlite-jdbc-jni-libs-${OS}sqlite-jdbc-jni-libs-allHere is the full list:
The Java code has been moved into a
sqlite-jdbc-jniproject/artifact. This does not include the native libs anymore.The existing
sqlite-jdbcproject/artifact has been replaced by an aggregation POM that will pull:sqlite-jdbc-jnisqlite-jdbc-jni-libs-allIt will not pull the Android libs, since anyway those have to be handled specifically and cannot be extracted from the JAR resources by the loader.