Skip to content

Add convention-aware updateManagedDependency API #214

@gnodet

Description

@gnodet

Summary

Add a public method to PomEditor.Dependencies that adds or updates a managed dependency while following the project's detected conventions (property creation, naming convention).

Current behavior

updateManagedDependency(boolean upsert, Coordinates coordinates) always inlines the raw version string when creating a new managed dependency (e.g., <version>2.0.13</version>). It does not create a version property or follow the project's detected conventions.

The convention-aware logic exists internally (in addAligned / alignDependency paths via resolveConventions, upsertVersionProperty, resolvePropertyName), but there's no public equivalent for managed dependency operations.

Proposed API

Something like:

// Convention-aware: detects project style and creates properties if needed
public boolean updateManagedDependencyAligned(boolean upsert, Coordinates coordinates);
public boolean updateManagedDependencyAligned(boolean upsert, Coordinates coordinates, AlignOptions options);

This should:

  1. Detect project conventions via resolveConventions(options)
  2. If versionSource == PROPERTY: generate the property name, call upsertVersionProperty, and use ${propName} as the version
  3. Call updateManagedDependency with the (possibly property-ref) version

Workaround

Users can currently combine detectConventions() + AlignOptions.generatePropertyName() + properties().updateProperty() + updateManagedDependency() manually, but this duplicates internal logic and is error-prone.

Claude Code on behalf of Guillaume Nodet

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions