gnodet opened a new pull request, #1600: URL: https://github.com/apache/maven-dependency-plugin/pull/1600
## Summary Alternative approach to #1599 — thin mojos leveraging existing libraries instead of hand-rolling XML/JSON manipulation: - **`dependency:add`** — adds/updates a dependency using [DomTrip](https://github.com/maveniverse/domtrip) for lossless POM editing (preserves formatting, comments, whitespace). Supports `-Dgav`, `-Dmanaged`, `-Dscope`, `-DuseProperty`, `-DpropertyName`. - **`dependency:remove`** — removes a dependency (regular or managed) using DomTrip. - **`dependency:search`** — searches Maven Central via the Sonatype Central Search API with proper JSON parsing (`jakarta.json`). Non-interactive tabular output. ### Key differences from #1599 | Aspect | #1599 | This PR | |--------|-------|---------| | POM editing | Hand-rolled DOM manipulation (~700 lines) | DomTrip `PomEditor` (~5 API calls) | | JSON parsing | Manual string manipulation (`findMatchingBrace`, `extractStringField`) | `jakarta.json` (already a project dependency) | | Search API | `search.maven.org` (deprecated) | `central.sonatype.com` (current) | | Interactive TUI | `System.console().readLine()` (no JLine) | None — tabular output suitable for scripting | | Total new code | ~6000 lines (3 mojos + helper classes) | ~460 lines (3 mojos, no helpers) | | Property support | No | Yes (`-DuseProperty`, `-DpropertyName`) | | Scope support | No | Yes (`-Dscope=test`) | ### Usage examples ```bash # Add a dependency mvn dependency:add -Dgav=com.google.guava:guava:33.0.0-jre # Add with scope and version property mvn dependency:add -Dgav=org.junit:junit-bom:5.11.0 -Dmanaged -Dscope=import -DuseProperty # Remove a dependency mvn dependency:remove -Dgav=commons-io:commons-io # Search Maven Central mvn dependency:search -Dquery=guava -Drows=10 ``` ### Dependencies added - `eu.maveniverse.maven.domtrip:domtrip-maven:0.6.0` (EPL-2.0, ASF Cat-B — already accepted in Maven 4 core) - `org.glassfish:jakarta.json:2.0.1` promoted from test to compile scope (already in the project) ## Test plan - [ ] CI build passes - [ ] Manual testing of `dependency:add` with various flag combinations - [ ] Manual testing of `dependency:remove` on regular and managed dependencies - [ ] Manual testing of `dependency:search` with free-text and field queries - [ ] Verify POM formatting preservation after add/remove operations 🤖 Generated with [Claude Code](https://claude.com/claude-code) _Claude Code on behalf of Guillaume Nodet_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
