brunoborges opened a new pull request, #1638: URL: https://github.com/apache/maven-dependency-plugin/pull/1638
Fixes #1637 ### Problem `dependency:add` with an explicit version added the dependency to the current POM's `<dependencyManagement>` instead of `<dependencies>` when the project's existing dependencies are version-less because their versions come from a **BOM import** — the layout produced by `maven-archetype-quickstart`. ```bash mvn dependency:add -Dgav=org.apache.commons:commons-lang3:3.20.0 ``` With `align=true` (default), `detectConventions()` set `useManaged=true` purely because most `<dependencies>` were version-less. As there was no parent POM to host the managed entry (`findManagedDepsPom()` returned `null`), the dependency was written into the current POM's `<dependencyManagement>` — so it was never actually added as a usable dependency. This also contradicts the `align` Javadoc, which says the convention is to *"add managed dependency to **parent POM**"*. ### Fix The auto-detected `useManaged` convention now only applies when a separate parent POM actually exists to host the managed dependency. For a single/leaf POM, a versioned add goes to `<dependencies>`. Explicit `-Dmanaged=true` is unchanged and still targets `<dependencyManagement>`. ### Testing - New integration test `src/it/projects/add-dependency/bom-import` reproduces the quickstart/BOM-import scenario and asserts the dependency lands in `<dependencies>` and **not** in `<dependencyManagement>`. - Existing `AddDependencyMojoTest` and `spotless:check` pass. - Manually verified against the reported scenario: `commons-lang3:3.20.0` is now correctly added to `<dependencies>`. -- 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]
