microsoft / vscode-maven

VSCode extension "Maven for Java"
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-maven
Other
179 stars 88 forks source link

Support "workspace resolution" like Eclipse/IntelliJ IDEA #778

Open mseele opened 2 years ago

mseele commented 2 years ago

Suggestion

Resolve Workspace artifacts like Eclipse/IntelliJ IDEA does.

Use Cases

We have multiple artifacts/modules/projects in one workspace that reference each other (like for example https://github.com/jdbi/jdbi). The Eclipse Maven plugin does what it calls "workspace resolution" for all artifacts that have a dependency which is in the workspace, too. This does not work inside a vscode workspace.

Examples

Example 1

Example 2

Eskibear commented 2 years ago

vscode maven extension uses (depgraph-maven-plugin)[https://github.com/ferstl/depgraph-maven-plugin] to calculate dependencies. It doesn't recognize dependency which is only in the workspace.

For Example 1, check output channel Maven for Java, I see below logs:

[INFO] Building jdbi3 SqlObject 3.27.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for org.jdbi:jdbi3-core:jar:3.27.1-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.jdbi:jdbi3-core:jar:tests:3.27.1-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.jdbi:jdbi3-testing:jar:3.27.1-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.jdbi:jdbi3-guava:jar:3.27.1-SNAPSHOT is missing, no dependency information available
[INFO] 
[INFO] --- depgraph-maven-plugin:3.3.0:graph (default-cli) @ jdbi3-sqlobject ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.444 s
[INFO] Finished at: 2022-01-12T09:48:13+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.ferstl:depgraph-maven-plugin:3.3.0:graph (default-cli) on project jdbi3-sqlobject: Unable to create dependency graph.: Could not resolve dependencies for project org.jdbi:jdbi3-sqlobject:jar:3.27.1-SNAPSHOT: The following artifacts could not be resolved: org.jdbi:jdbi3-core:jar:3.27.1-SNAPSHOT, org.jdbi:jdbi3-core:jar:tests:3.27.1-SNAPSHOT, org.jdbi:jdbi3-testing:jar:3.27.1-SNAPSHOT, org.jdbi:jdbi3-guava:jar:3.27.1-SNAPSHOT: Could not find artifact org.jdbi:jdbi3-core:jar:3.27.1-SNAPSHOT -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Unfortunately the only workaround I can think of for the moment is, you mvn install these modules manually...

I don't know how IDEA and Eclipse resolve this, let me know if you have any clue.

mseele commented 2 years ago

I did a quick search in the m2e code (the eclipse maven plugin) and it looks like these classes have to do with workspace resolution in eclipse:

Just search for workspace resolution, maybe you get a few hints how to do this. I evaluate the switch of our java development from eclipse to vscode and this is an essential feature I'm missing on vscode for now...

Eskibear commented 2 years ago

Thank you for the information, and this is definitely a key feature we want to implement. (I don't want to mvn install all my WIP modules either)

We've been avoiding to invent wheels and that's the reason why we simply delegate dependency resolution to existing maven plugins. Two options come to my mind now:

Question for @testforstephen @jdneo : can we expose vscode-java API to fetch dependencies information, including projects in workspace?

mseele commented 2 years ago

@Eskibear Is there anything I can help to get this request further?

Eskibear commented 2 years ago

As I mentioned above, the biggest problem is, we don't calculate Maven models inside this extension. And most of the features are around Maven CLI (as it's originally designed). Without information of Maven models, there are a lots of disadvantages. E.g. no good profiles support, not all properties are resolved...etc. The ideal way is that m2e exposes the models (via vscode-java extension API probably), then it should work well without inconsistency. If we have to implement something to host the Maven model, despite of the effort, a big problem is how we keep consistent with m2e inside vscode-java extension, especially when there's customized configs.

brianmichalk1 commented 4 months ago

Is there any movement on this, or is there a different way to implement this?