charangowdamd-cmd commented on code in PR #13715:
URL: https://github.com/apache/maven/pull/13715#discussion_r4390178727
##########
compat/maven-model-builder/src/main/java/org/apache/maven/model/composition/DefaultDependencyManagementImporter.java:
##########
@@ -62,11 +64,21 @@ public void importManagement(
target.setDependencyManagement(depMgmt);
}
+ Set<String> directDependencies = new
HashSet<>(dependencies.keySet());
+
for (DependencyManagement source : sources) {
for (Dependency dependency : source.getDependencies()) {
String key = dependency.getManagementKey();
- if (!dependencies.containsKey(key)) {
+ Dependency present = dependencies.get(key);
+ if (present == null) {
dependencies.put(key, dependency);
+ } else if (directDependencies.contains(key)
+ && present.getVersion() == null
+ && dependency.getVersion() != null) {
+ Dependency updated = present.clone();
+ updated.setVersion(dependency.getVersion());
+ updated.setLocation("version",
dependency.getLocation("version"));
+ dependencies.put(key, updated);
}
}
}
Review Comment:
Thanks for pointing this out. I understand the concern about maintaining
behavioral consistency between Maven 3.x and the compatibility layer in Maven 4.
I'll investigate the existing implementation in `maven-3.10.x` and determine
the appropriate way to address this issue in the Maven 3.x
`maven-model-builder` module first. I'll also check with the maintainers
regarding the expected backport and compatibility policy before proceeding with
changes to this PR.
I appreciate the review and guidance.
--
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]