I tried to search the existing issues and could not find this particular issue discussed anywhere. If I open VS Code with a simple Maven project (single pom.xml, no sub-modules) and there are Gradle projects existing within the target folder then the maven project is not detected and its dependencies and source folders are not added to the Java source paths list.
To fix the issue I must run a mvn clean on the project and clean the language server workspace for the maven project to be detected. Afterwards I can build and restart and everything works as expected (and the gradle projects are added to the source list along with the maven projects) as long as I don't clean the workspace and restart without cleaning the maven target folder as well.
Took me several hours to track down why the project stopped working so hopefully I can save someone else from that frustration.
List all Java source pathsmvn packageList all Java source pathsMaven paths do not load if gradle paths are found in subfolders
Both maven paths and gradle paths should load correctly, regardless of additional projects found in subfolders.
Seems related to #600
@sfariaNG you can try the following settings:
"java.import.exclusions": [
"**/node_modules/**",
"**/.metadata/**",
"**/archetype-resources/**",
"**/META-INF/maven/**",
"**/target/**"
],
or
"java.import.gradle.enabled": false,
Thanks @snjeza, it looks like setting those exclusions does the trick and intellisense is maintained as long as my .classpath is setup correctly. I still think this is a bug that should be addressed as it doesn't make sense to behave differently in the two scenarios, but this workaround is sufficient in the meantime. Not sure how you all want to handle this ticket.
Most helpful comment
Fixed with https://github.com/eclipse/eclipse.jdt.ls/pull/1532