Maven project inside another maven project not recognized
When you have a maven project inside another maven project, only the top level project is properly recognized in the java projects view. However, if the sub-project is opened in another window by itself, the project is properly recognized
Environment
- Operating System: Fedora 38
- JDK version: openjdk 17.0.7
- Visual Studio Code version: 1.81.0
- Java extension version: 1.21.0
Steps To Reproduce
- Create new maven project (using maven for java extension)
- Create new maven project inside project from step 1. Example structure below:
test_project/
src/
main/
java/
TestMain.java
pom.xml
sub_project/
src/
main/
java/
SubMain.java
pom.xml
- Import Java Projects into Workspace
- Observe only
test_projectis properly imported in this case - Open a new window: File > New Window
- Inside new window, open
sub_project: File > Open Folder > selectsub_project - Observe
sub_projectcan now be recognized as a java project
Current Result
Only top level projects are recognized, projects inside projects are not. This leads to the warning SubMain.java is not on the classpath of project test_project, only syntax errors are reported and many features of the extension not working
Expected Result
Projects are recursively detected by their pom files and the extension features can be used for projects inside projects
We have found issues that are potential duplicates:
- #3221 (61.25%)
If any of the issues listed above are a duplicate, please consider closing this issue & upvoting/commenting the original one. Alternatively, if neither of the listed issues addresses your feature/bug, keep this issue open.
To recognize nested projects, you need the top project to be have "pom" packaging, and declare the sub project as a module. "pom" projects can't contain java code.
Maybe I shouldn't have called it a sub project, I don't want the projects to be "connected" per se; I don't need to use the "sub" project inside the top project. They are separate projects, but for the directory structure it makes sense to store project A inside project B, other than that they are not related. Would that be possible?
no, as soon as the non-"pom" top project is detected, we stop crawling down to find other projects
Could a setting be added to make this configurable? Or allow users to manually select directories to import as a java project?
I have a monorepo setup with multiple subprojects on different languages, would be good to have some way to support this.