eclipse-m2e / m2e-core

Eclipse Public License 2.0
114 stars 117 forks source link

Project with module-info not runnable #1272

Open dsyer opened 1 year ago

dsyer commented 1 year ago

As reported here: https://github.com/redhat-developer/vscode-java/issues/881. It's also a problem with Gradle so most of that issue is about that, but there doesn't seem to be an issue logged for Maven, so this is a starting point for that.

Repeating what I said there: just download a project from start.spring.io and add a module-info.java. You might need to tweak the one that VSCode generates for you. This worked for me in a vanilla Boot/Webflux app with Actuators:

module demo {
    exports com.example.demo;

    requires spring.beans;
    requires spring.boot;
    requires spring.boot.autoconfigure;
    requires spring.boot.actuator;
    requires spring.boot.actuator.autoconfigure;
    requires spring.context;
    requires spring.core;
    requires spring.web;

    opens com.example.demo to //
            spring.core, spring.web, spring.beans, spring.context, spring.boot, com.fasterxml.jackson.databind;
}

YMMV. I had to delete the tests because VSCode is confused about test dependencies and the module path. And the app was runnable from the command line, but not in the IDE (incomprehensible errors starting with java.instrument not being available).

You can get something to work by adding java.instrument to the requirements in module-info, but since that isn't actually a requirement, that seems like a bug. I also have experienced other issues once that one is out of the way, but those do not show up with the simple out of the box project as described above.

laeubi commented 1 year ago

@dsyer thanks for you report, sadly module support has gotten very little interest by the usual m2e contributors and it seems this is not really something the usual committer/contributors encounter and thus handled with very low priority, so probably you like to provide a PR to fix that together with a test-case to verify it works?

Beside that, sponsoring is a good way to get specific issues fixed, so if this is crucial to your business and you likes to speed up the development of m2e in general a sponsoring would allow me to assign more time-slots to bug fixing or contact me for an individual contract for example fixing a specific issue.

dsyer commented 1 year ago

No thanks. I don't personally care that much, but it's good to have a place to send people if they come across this problem. The fact that m2e did not track this bug seemed like an omission.

laeubi commented 1 year ago

@dsyer there are some issues regarding module support, but as said no one has cared (enough) at the moment:

and honestly if vscode-java is using m2e it should be there concern to help addressing issues in libraries they depend on so feel free to "send people here" but don't expect that this changes much unless some dev-effort or money is contributed or someone find it interesting enough to fix it.