Open
Description
Since yesterday's "Project Manager for Java" release, additional dependencies added to JavaFX do not work.
I am making a Java FX project. This is based on Maven. It works.
When I add an extra dependency like Gson.
com.google.code.gson gson 2.11.0I write in the code:
Gson gson = new Gson();
I import as usual.
The dependency cannot be used. VSCode says Gson cannot be resolved. It is there in the pom.xml file, and the import is also there in the code.
I saw that other people had previously written that, due to modularization, the following must be entered in the module-info.java file:
requires com.google.gson;
But even this instruction gives me trouble, you can't even find the module here.
I used it 3 days ago and there were no problems with it.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
jdneo commentedon Nov 10, 2024
Have you tried right click on the pom file and select Reload Project?
andteki commentedon Nov 10, 2024
Hello jdneo!
Not before your message, but I tried. Of course it doesn't help.
I also tried "mvn clean install", etc.
But I have since narrowed down the problem. The error only occurs with the latest version of Gson, which is: 2.11.0
The problem only occurs when I use JavaFX. I see that the point is not JavaFX, but the modular program (module-info.java). I'm writing a simple Maven project that works non-modularly on Gson 2.11.0.
Let's stick with the modular JavaFX program:
If I switch back to the previous version of Gson, 2.10.1 or earlier, it works.
I looked into the Gson source code. Earlier versions of Gson are also modular. So it's not a problem. I see they introduced a new thing: proguard. I just suspect that might be causing the problem. I didn't go through it in detail.
The concrete phenomenon:
If you have this in pom.xml:
I have a line like this in the module-info.java file:
After the word requires, com.google.gson is underlined in red. If I move the mouse towards it, it says:
"com.google.gson cannot be resolved to a module"
(
Gson 2.11.0 also works in NetBeans for Maven-based and modular JavaFX projects.
)
jdneo commentedon Nov 11, 2024
Would you mind sharing a sample project for this issue?
andteki commentedon Nov 11, 2024
Here it is:
https://github.com/andteki/samplefx.git
Now, the Gson version is 2.11.0, so not working.
If you write the version 2.10.1, then works.
https://central.sonatype.com/artifact/com.google.code.gson/gson
jdneo commentedon Nov 12, 2024
Looks like it's a bug from upstream:
Related issues:
google/gson#2721
eclipse-jdt/eclipse.jdt.core#2495
For now the workaround is to use gson@2.10.1
Sorry for the inconvenience.
andteki commentedon Nov 13, 2024
Thank you for your work!