Summary
Add convention auto-detection to PomEditor.Dependencies so that when adding a dependency, the edit follows the project's existing dependency management style.
Claude Code on behalf of Guillaume Nodet
Motivation
Multiple tools need this capability:
Currently each consumer must implement its own convention detection. This logic belongs in domtrip-maven's PomEditor since it's a POM editing concern.
Proposed API
// High-level: detect conventions and add accordingly
editor.dependencies().addAligned(Coordinates coords);
// Or with explicit control:
editor.dependencies().addAligned(Coordinates coords, AlignOptions options);
Convention Detection
When adding a dependency, analyze existing <dependencies> and <properties> to detect:
1. Managed dependency style
- If most existing
<dependency> entries are version-less (version delegated to <dependencyManagement>), the new dependency should be added the same way:
- Add versioned entry to
<dependencyManagement>
- Add version-less
<dependency>
- If most entries have inline versions, add with inline version
2. Version property style
- If most existing versions use
${...} property references, automatically create a version property
- If most use literal versions, use literal
3. Property naming convention
Detect the dominant pattern from existing properties:
- Dot suffix:
guava.version → ${guava.version}
- Dash suffix:
guava-version → ${guava-version}
- CamelCase:
guavaVersion → ${guavaVersion}
- Dot prefix:
version.guava → ${version.guava}
Apply the same pattern when creating new version properties.
Implementation Notes
- The
PomEditor.Properties API already exists (updateProperty(), deleteProperty()) but is underutilized
PomEditor.Dependencies already has updateDependency() and updateManagedDependency() — the aligned version composes these
- Explicit flags should always override detected conventions (e.g., force managed, force property, explicit property name)
- Detection should be based on majority vote — if 7/10 deps use properties, follow that pattern
Acceptance Criteria
Summary
Add convention auto-detection to
PomEditor.Dependenciesso that when adding a dependency, the edit follows the project's existing dependency management style.Claude Code on behalf of Guillaume Nodet
Motivation
Multiple tools need this capability:
dependency:addgoal with-DalignflagCurrently each consumer must implement its own convention detection. This logic belongs in
domtrip-maven'sPomEditorsince it's a POM editing concern.Proposed API
Convention Detection
When adding a dependency, analyze existing
<dependencies>and<properties>to detect:1. Managed dependency style
<dependency>entries are version-less (version delegated to<dependencyManagement>), the new dependency should be added the same way:<dependencyManagement><dependency>2. Version property style
${...}property references, automatically create a version property3. Property naming convention
Detect the dominant pattern from existing properties:
guava.version→${guava.version}guava-version→${guava-version}guavaVersion→${guavaVersion}version.guava→${version.guava}Apply the same pattern when creating new version properties.
Implementation Notes
PomEditor.PropertiesAPI already exists (updateProperty(),deleteProperty()) but is underutilizedPomEditor.Dependenciesalready hasupdateDependency()andupdateManagedDependency()— the aligned version composes theseAcceptance Criteria
addAligned()method that applies detected conventions