Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maven projects not detected when gradle found #1344

Closed
sfariaNG opened this issue Mar 26, 2020 · 3 comments
Closed

Maven projects not detected when gradle found #1344

sfariaNG opened this issue Mar 26, 2020 · 3 comments

Comments

@sfariaNG
Copy link

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.

Environment
  • Operating System: Windows 10 Pro
  • JDK version: OpenJDK 1.8
  • Visual Studio Code version: 1.43.2
  • Java extension version: 0.59.0-2069
Steps To Reproduce
  1. Open VS Code and load sample-test folder
  2. Wait for Java Language Server to finish loading
  3. Run command List all Java source paths
  4. Note 5 maven project paths listed
  5. Run mvn package
  6. If you restart VS Code now and list source paths you should see the 5 maven paths and 2 new gradle paths
  7. Clean the Java Language Server Workspace and restart VS Code
  8. Wait for Java Language Server to finish loading and run command List all Java source paths
  9. Note that only 2 gradle paths are listed, the maven paths do not load

sample-test.zip

Current Result

Maven paths do not load if gradle paths are found in subfolders

Expected Result

Both maven paths and gradle paths should load correctly, regardless of additional projects found in subfolders.

Additional Informations

Seems related to #600

@snjeza
Copy link
Contributor

snjeza commented Mar 26, 2020

@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,

@sfariaNG
Copy link
Author

sfariaNG commented Mar 26, 2020

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.

@fbricon
Copy link
Collaborator

fbricon commented Sep 15, 2020

Fixed with eclipse-jdtls/eclipse.jdt.ls#1532

@fbricon fbricon closed this as completed Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants