jjkester commented on a change in pull request #603:
URL: https://github.com/apache/maven/pull/603#discussion_r746013619
##########
File path:
maven-model-builder/src/main/java/org/apache/maven/model/composition/DefaultDependencyManagementImporter.java
##########
@@ -83,4 +90,43 @@ public void importManagement( Model target, List<? extends
DependencyManagement>
}
}
+ static void updateDependencyHierarchy( Dependency dependency,
DependencyManagement bom )
+ {
+ // We are only interested in the InputSource, so the location of the
<dependency> element is sufficient
+ InputLocation dependencyLocation = dependency.getLocation( "" );
+ InputLocation bomLocation = bom.getLocation( "" );
+
+ if ( dependencyLocation == null || bomLocation == null )
+ {
+ return;
+ }
+
+ InputSource hierarchicalSource = dependencyLocation.getSource();
Review comment:
That is interesting. `InputLocation` is tied to a specific line in the
file, so making those hierarchical would only work for single locations. Given
that a dependency has many, we either need to decide on what to track or just
modify them all (the latter would of course be much more generic). Since the
`InputSource` objects are per-file, that is just a quick way to get some order.
Just to check your suggestion, would your idea be that an `InputSource`
refers to the `InputLocation` where it is referenced? In that case (keeping in
mind a more generic solution), I think there are a few things to investigate:
- Is there a place in the code where we have access to the `InputLocation`
of the reference (parent, import, ...) and the `InputSource` of the referenced
POM?
- In this place in the code, is the model already a tree or is it a graph?
I.e., is there only one path from the root POM to every other (indirectly)
referenced POM?
A simple test case for the latter could be a project like this:
```
pom.xml --imports-> bom1
| |
imports imports
| |
v v
parent --imports-> bom2
|
imports
|
v
bom3
```
There are two paths to resolve a dependency defined in `bom3`, ideally there
should be a deterministic way to define the path that Maven takes. And that
path should (in my opinion) be accurately reflected in the model. Currently my
knowledge is too limited to determine how Maven actually resolves this.
--
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]