vscode-maven icon indicating copy to clipboard operation
vscode-maven copied to clipboard

Support "workspace resolution" like Eclipse/IntelliJ IDEA

Open mseele opened this issue 4 years ago • 6 comments

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

  • Clone https://github.com/jdbi/jdbi
  • Run code . inside the cloned directory
  • Open Maven View, project jdbi3 SqlObject, open Dependencies
  • You get a failure that the dependencies could not be resolved

Example 2

  • Clone https://github.com/jdbi/jdbi
  • Run code . inside the cloned directory
  • Open sqlobject/pom.xml in editor
  • Do a control+click on dependency jdbi3-core
  • You get a failure that the dependency could not be resolved

mseele avatar Jan 11 '22 15:01 mseele

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.

Eskibear avatar Jan 12 '22 02:01 Eskibear

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...

mseele avatar Jan 12 '22 06:01 mseele

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:

  • Implement similar resolution mechanism if we have to. 😿
  • Request dependency information from vscode-java extension (if installed) which already resolves your projects with m2e, if possible.

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

Eskibear avatar Jan 12 '22 07:01 Eskibear

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

mseele avatar Jul 12 '22 06:07 mseele

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.

Eskibear avatar Jul 12 '22 07:07 Eskibear

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

brianmichalk1 avatar Mar 28 '24 14:03 brianmichalk1