objectbox / objectbox-java

Android Database - first and fast, lightweight on-device vector database
https://objectbox.io
Apache License 2.0
4.38k stars 302 forks source link

Support the Java module system (JPMS) #840

Open Burtan opened 4 years ago

Burtan commented 4 years ago

Any plans to support Java Platform Module System (JPMS)? Currently I get errors on a minimal gradle kotlin jpms example and I couldn't find any documentation on jpms with objectbox. It's finally pushed with future gradle versions. So it would be nice to add support :-).

greenrobot-team commented 4 years ago

Thanks for bringing this to our attention.

Notes:

Edit: also not documented, yet. And more links:

Burtan commented 4 years ago

Any update on a time schedule for this? Or is this on low priority?

greenrobot commented 4 years ago

Are the prerequisites (e.g. Gradle) now in place (cc @greenrobot-team)?

Burtan commented 4 years ago

At least Gradle 6.4 is released.

greenrobot-team commented 4 years ago

Yes, as far as I can tell.

Burtan commented 4 years ago

One more thing to keep in mind. Android does not support JPMS and it relies on byte code < JDK8. So libraries have to compile the java-module.info file with JDK9+ and the rest with JDK8. Java-Modularity plugin for gradle might help.

Burtan commented 3 years ago

Is this addressed with Objectbox 3.0.0+?

Burtan commented 3 years ago

Any news on this? Meanwhile gradle 6.8.1 enables module support by default.

greenrobot-team commented 3 years ago

No updates because there are no updates :)

Burtan commented 3 years ago

I tried to get ObjectBox 3.0.0-alpha2 working with JPMS. It is better than 2.x.x because io.objectbox.converter is no longer split across two packages (java and java-api). I was able to generate module names using this plugin id("de.jjohannes.extra-java-module-info") version "0.3" However, the objectbox gradle plugins makes all modules fail.

/.../src/main/java/module-info.java:2: error: module not found: kotlin.stdlib
    requires kotlin.stdlib;

If the gradle errors are fixed I think Objectbox 3.0.0-alpha2 could be used with JPMS without too much trouble. If it helps I could create an example repo on github.

kinsleykajiva commented 2 years ago

any update on this ?

IranLaserProgrammer commented 4 months ago

waiting for fixing this issue, any updates??

greenrobot-team commented 4 months ago

@IranLaserProgrammer Does lack of support for the module system prevent using ObjectBox in your project? If yes, can you share some details on what you are trying to do? I'm just trying to get a feeling on how important this is.

kinsleykajiva commented 4 months ago

Hi @greenrobot-team , thanks for responding to this , this is also a problem when using this on other platforms like Desktops, where in most cases, Java projects use the module system by default (which doesn't mean we can ignore modules). In my case, I would imagine it's the same for other developers—to benefit from the module tools. However, in many cases, one can hit a brick wall when it comes to Gradle. I am a big fan of this project, but I realized there was no workaround for this in one of my projects. I had to remove the module info file just to accommodate the database. You can imagine the pain points as one of the users here.

greenrobot-team commented 4 months ago

@kinsleykajiva thanks. I still need to research this more. If I see this correctly this requires compiling with Java language level 9 to spot any errors. However, to support as many Android versions as possible, then to release a version compiled with language level set to Java 8. Then, the library might not work on Android at all (info from 2018 though).

Maybe it can be enough to just add and reserve a module name for each Maven artifact (Automatic-Module-Name attribute), so it's future proof to use the libraries in a module-based project.

In any case, can't find any good resource on migrating an existing library. So tips are welcome!

Created an internal issue for this (objectbox/objectbox-java#211).

IranLaserProgrammer commented 4 months ago

I am creating a desktop application with java in IntelliJ. Because of this problem i can't have a modular base project and this is a problem. I lose the advantages of a modular project. Hope you fix it soon. Tnx