You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "brunoborges (via GitHub)" <gi...@apache.org> on 2026/05/29 20:46:49 UTC

[PR] [#1637] Fix dependency:add routing versioned deps into dependencyManagement [maven-dependency-plugin]

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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#1637] Fix dependency:add routing versioned deps into dependencyManagement [maven-dependency-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski merged PR #1638:
URL: https://github.com/apache/maven-dependency-plugin/pull/1638


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#1637] Fix dependency:add routing versioned deps into dependencyManagement [maven-dependency-plugin]

Posted by "brunoborges (via GitHub)" <gi...@apache.org>.
brunoborges commented on code in PR #1638:
URL: https://github.com/apache/maven-dependency-plugin/pull/1638#discussion_r3397340139


##########
src/it/projects/add-dependency/bom-import/pom.xml:
##########
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>test</groupId>
+    <artifactId>add-dependency-bom-import</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.junit</groupId>
+                <artifactId>junit-bom</artifactId>
+                <version>5.11.0</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>

Review Comment:
   @slawekjaranowski can we merge this one as is, and I will submit another PR changing all artifacts to non-existent examples.



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#1637] Fix dependency:add routing versioned deps into dependencyManagement [maven-dependency-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #1638:
URL: https://github.com/apache/maven-dependency-plugin/pull/1638#discussion_r3383678837


##########
src/it/projects/add-dependency/bom-import/pom.xml:
##########
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>test</groupId>
+    <artifactId>add-dependency-bom-import</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.junit</groupId>
+                <artifactId>junit-bom</artifactId>
+                <version>5.11.0</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>

Review Comment:
   I hope we can use for such example any no existing artifacts, (like org.example:bom) as ddd mojo not require dependencies resolving, or we can add next mock artifact like a1 is.
   
   When we merge it dependabot will try to updates it, and we will have next maintenance works on list
   



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#1637] Fix dependency:add routing versioned deps into dependencyManagement [maven-dependency-plugin]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #1638:
URL: https://github.com/apache/maven-dependency-plugin/pull/1638#issuecomment-4685151860

   @slawekjaranowski Please assign appropriate label to PR according to the type of change.


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#1637] Fix dependency:add routing versioned deps into dependencyManagement [maven-dependency-plugin]

Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #1638:
URL: https://github.com/apache/maven-dependency-plugin/pull/1638#discussion_r3399215398


##########
src/it/projects/add-dependency/bom-import/pom.xml:
##########
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>test</groupId>
+    <artifactId>add-dependency-bom-import</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.junit</groupId>
+                <artifactId>junit-bom</artifactId>
+                <version>5.11.0</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>

Review Comment:
   ok, waiting for next PR 😄 



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#1637] Fix dependency:add routing versioned deps into dependencyManagement [maven-dependency-plugin]

Posted by "brunoborges (via GitHub)" <gi...@apache.org>.
brunoborges commented on PR #1638:
URL: https://github.com/apache/maven-dependency-plugin/pull/1638#issuecomment-4603071837

   Hey folks, can I get a review on this fix? 
   
   @cstamas @slawekjaranowski @slachiewicz 


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org