fix(maven): replace internal MavenGeneralSettings.getLocalRepository() API#255
Conversation
…) API Use MavenProjectsManager.getRepositoryPath() which is public in both IntelliJ 2025.1 and 2025.2, instead of the internal getLocalRepository() method that was marked @ApiStatus.Internal in IC-252. Implements TC-4168 Assisted-by: Claude Code
Review Summary by QodoReplace internal Maven API with public alternative
WalkthroughsDescription• Replace internal MavenGeneralSettings.getLocalRepository() with public MavenProjectsManager.getRepositoryPath() API • Extract project resolution logic into reusable getProject() helper method • Ensure compatibility with IntelliJ 2025.1 and 2025.2 public APIs Diagramflowchart LR
A["MavenSettingsUtil.getLocalRepository()"] -->|"old: internal API"| B["MavenGeneralSettings.getLocalRepository()"]
A -->|"new: public API"| C["MavenProjectsManager.getRepositoryPath()"]
D["getProject() helper"] -->|"used by"| A
D -->|"used by"| E["getMavenGeneralSettings()"]
File Changes1. src/main/java/org/jboss/tools/intellij/settings/MavenSettingsUtil.java
|
Code Review by Qodo
1. Mixed project Maven settings
|
|
| public static String getLocalRepository() { | ||
| MavenGeneralSettings settings = getMavenGeneralSettings(); | ||
| return settings.getLocalRepository(); | ||
| return MavenProjectsManager.getInstance(getProject()).getRepositoryPath().toString(); |
There was a problem hiding this comment.
1. Mixed project maven settings 🐞 Bug ≡ Correctness
MavenSettingsUtil.getLocalRepository() now resolves the repo path from MavenProjectsManager.getInstance(getProject()) on every call, while getUserSettingsFile()/isMavenWrapperSelected() use a static cached MavenGeneralSettings captured once. If the set/order of open projects changes (or multiple projects are open), ApiService can export Maven user settings from one project and the local repository from another, producing incorrect Maven environment properties for analysis.
Agent Prompt
### Issue description
`MavenSettingsUtil.getLocalRepository()` now derives the repository path from `MavenProjectsManager.getInstance(getProject())` each call, while other Maven settings (`getUserSettingsFile()`, `isMavenWrapperSelected()`) are derived from a statically cached `MavenGeneralSettings` captured once. This can mix settings across different open projects.
### Issue Context
`ApiService#setRequestProperties` sets multiple Maven-related system properties in one call path. These values must be resolved from the same `Project` instance to avoid exporting an inconsistent Maven configuration.
### Fix Focus Areas
- Align all Maven settings methods to use the same `Project` instance (preferably passed in from the caller rather than using `openProjects[0]`).
- Remove/avoid static cross-project caching of `MavenGeneralSettings`, or cache per-project if caching is required.
- src/main/java/org/jboss/tools/intellij/settings/MavenSettingsUtil.java[13-47]
- src/main/java/org/jboss/tools/intellij/exhort/ApiService.java[153-165]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Summary
MavenGeneralSettings.getLocalRepository()(internal API in IC-252) withMavenProjectsManager.getInstance(project).getRepositoryPath()(public in both 2025.1 and 2025.2)getProject()helper inMavenSettingsUtilgetUserSettingsFile(),getMavenHomeType(), orMavenWrapper— all confirmed publicImplements TC-4168
Test plan
./gradlew compileJavapasses./gradlew verifyPlugin—MavenGeneralSettings.getLocalRepository()no longer flagged./gradlew test— all existing tests pass🤖 Generated with Claude Code