eclipse.jdt.ls icon indicating copy to clipboard operation
eclipse.jdt.ls copied to clipboard

`java.project.getAll` not returning all projects if 2 share the same `artifactId` even with different `groupId`

Open tylerwowen opened this issue 4 years ago • 1 comments

First I'm quite new to Java development, so please do let me know if this is because I'm not following some convention.

The problem appears in VS Code. I did a little debugging and the problem seems to be in the language server.

I discovered that if there are 2 maven projects in the same folder and share the same artifactId but different groupId, then only one is returned by java.project.getAll. I don't have a setup like this and this is for demonstration only. But I have a multi-root workspace in VS Code which isn't unusual to have 2 projects share the same artifactId.

tylerwowen avatar Mar 08 '22 01:03 tylerwowen

I was able to reproduce as well. one of the projects is not detected.

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-08-24 22:40:36.333
!MESSAGE Importing Maven project(s)

!ENTRY org.eclipse.jdt.ls.logback.appender 1 0 2022-08-24 22:47:55.452
!MESSAGE Using manager EnhancedLocalRepositoryManager with priority 10.0 for /home/rgrunber/.m2/repository

!ENTRY org.eclipse.jdt.ls.logback.appender 1 0 2022-08-24 22:48:20.756
!MESSAGE Imported project my-app-parent (1/3) in 7683 ms

!ENTRY org.eclipse.jdt.ls.logback.appender 1 0 2022-08-24 22:49:35.938
!MESSAGE Imported project my-app (2/3) in 72300 ms

!ENTRY org.eclipse.jdt.ls.logback.appender 4 0 2022-08-24 22:50:47.387
!MESSAGE Project my-app already exists

This happens at https://github.com/eclipse-m2e/m2e-core/blob/6259d8e86cb207bff1c62a6a5e6dc68ae8671507/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java#L799-L803 because ProjectConfigurationManager#getProjectName(..) only takes the artifactID into consideration.

rgrunber avatar Aug 25 '22 02:08 rgrunber

This is fixed now but I suspect we may have some other issues in this kind of project (same artifactIds) where JDT-LS might incorrectly be trying to use the project name (artifactId) to get the project information. Of course, I think it's better to uncover and fix those issues than just have the project not be imported at all.

rgrunber avatar Mar 20 '23 20:03 rgrunber