fix: workspace discovers projects in subdirectories (#9) #10

Merged
fred merged 2 commits from fix/9-workspace-project-discovery into main 2026-03-06 18:51:56 +00:00
Collaborator

Summary

Fixes #9jdt_list_projects returns 0 projects when the working directory is a workspace containing multiple projects as subdirectories.

Root Causes

  1. ProjectImporter only checked the root directory for .project/pom.xml — workspace directories with subprojects were not scanned
  2. jdt_refresh_project (workspace-wide) only did refreshLocal() but never discovered new projects
  3. No manual import mechanism existed as fallback

Changes

  • ProjectImporter.java — New scanSubdirectories() method: when root has neither .project nor pom.xml, scans immediate subdirectories for projects. New public importFromPath() for external callers.
  • ProjectInfoTools.java — Workspace-level refresh now also runs ProjectImporter.importFromPath(). New tools: jdt_import_project (import from any path) and jdt_remove_project (remove from workspace).
  • McpServerManager.java — Registers both new tools (44 → 46 tools).

Workflow After Fix

  1. Auto-import at startup now finds projects in subdirectories
  2. jdt_refresh_project (no params) additionally discovers new projects
  3. jdt_import_project allows targeted import of any directory
  4. jdt_remove_project allows cleanup of unwanted projects
## Summary Fixes #9 — `jdt_list_projects` returns 0 projects when the working directory is a workspace containing multiple projects as subdirectories. ### Root Causes 1. `ProjectImporter` only checked the root directory for `.project`/`pom.xml` — workspace directories with subprojects were not scanned 2. `jdt_refresh_project` (workspace-wide) only did `refreshLocal()` but never discovered new projects 3. No manual import mechanism existed as fallback ### Changes - **`ProjectImporter.java`** — New `scanSubdirectories()` method: when root has neither `.project` nor `pom.xml`, scans immediate subdirectories for projects. New public `importFromPath()` for external callers. - **`ProjectInfoTools.java`** — Workspace-level refresh now also runs `ProjectImporter.importFromPath()`. New tools: `jdt_import_project` (import from any path) and `jdt_remove_project` (remove from workspace). - **`McpServerManager.java`** — Registers both new tools (44 → 46 tools). ### Workflow After Fix 1. Auto-import at startup now finds projects in subdirectories 2. `jdt_refresh_project` (no params) additionally discovers new projects 3. `jdt_import_project` allows targeted import of any directory 4. `jdt_remove_project` allows cleanup of unwanted projects
ProjectImporter now scans subdirectories when the root directory has no
.project or pom.xml, fixing the case where jdt_list_projects returns 0
for workspace directories containing multiple projects.

Also adds jdt_import_project and jdt_remove_project tools for explicit
project management, and enhances workspace-level refresh to discover
new projects.

Closes #9

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Re-resolves Maven dependencies and updates the JDT classpath after
pom.xml changes. Uses mvn dependency:build-classpath to resolve
dependencies, then replaces library entries in the project classpath.

Closes #4

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fred merged commit 37c8f19818 into main 2026-03-06 18:51:56 +00:00
Sign in to join this conversation.
No description provided.