[ 
https://issues.apache.org/jira/browse/MNG-7344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17836470#comment-17836470
 ] 

ASF GitHub Bot commented on MNG-7344:
-------------------------------------

juulhobert commented on code in PR #603:
URL: https://github.com/apache/maven/pull/603#discussion_r1562205753


##########
maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java:
##########
@@ -1683,13 +1684,20 @@ private void importDependencyManagement(
 
             it.remove();
 
+            // Model v3
             DependencyManagement importMgmt = loadDependencyManagement(model, 
request, problems, dependency, importIds);
+            if (importMgmt == null) {
+                continue;
+            }
 
-            if (importMgmt != null) {
-                if (importMgmts == null) {
-                    importMgmts = new ArrayList<>();
-                }
-
+            if (request.isLocationTracking()) {
+                // Keep track of why this DependencyManagement was imported.
+                // And map model v3 to model v4 -> 
importMgmt(v3).getDelegate() returns a v4 object
+                importMgmts.add(
+                        
org.apache.maven.api.model.DependencyManagement.newBuilder(importMgmt.getDelegate(),
 true)
+                                
.importedFrom(dependency.getDelegate().getLocation(""))

Review Comment:
   @hboutemy you're right. It should only map it from model v3 to model v4. 
We're going to remove the line 
`.importedFrom(dependency.getDelegate().getLocation(""))`





> Effective pom should contain more finegrained details regarding its content 
> origin: track dependencyManagement import
> ---------------------------------------------------------------------------------------------------------------------
>
>                 Key: MNG-7344
>                 URL: https://issues.apache.org/jira/browse/MNG-7344
>             Project: Maven
>          Issue Type: Improvement
>          Components: Inheritance and Interpolation, POM
>            Reporter: Robert Scholte
>            Priority: Major
>             Fix For: 3.9.x-candidate, 4.0.x-candidate
>
>         Attachments: MicrosoftTeams-image.png
>
>
> To support MPH-183 some changes needs to be done in Maven Core.
> For every element that is not part of the raw model, it must be possible to 
> get the "resolution path" to that element. 
> Until now, only the usual pure inheritance is tracked though InputLocation, 
> as done in MNG-1803, later displayed by verbose help effective-pom with 
> MPH-160
> The following are known to add elements to the effective pom:
> - BOMs dependencyManagement import
> - [Tiles Maven Plugin|https://github.com/repaint-io/maven-tiles] by [~talios]
> Without this feature, it is very hard to detect where these extra elements 
> are coming from.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to