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

Hervé Boutemy commented on MPH-160:
-----------------------------------

Studying how to track finely input location for plugins configuration:
1. at read time, in [{{MavenXpp3ReaderEx}} code, line 3349 for Maven 
3.6.0|https://maven.apache.org/ref/3.6.0/maven-model/xref/org/apache/maven/model/io/xpp3/MavenXpp3ReaderEx.html#L3349]
 generated by xpp3-extended-reader:
{code:java}            else if ( checkFieldWithDuplicate( parser, 
"configuration", null, parsed ) )
            {
                _location = new InputLocation( parser.getLineNumber(), 
parser.getColumnNumber(), source );
                plugin.setLocation( "configuration", _location );
                plugin.setConfiguration( 
org.codehaus.plexus.util.xml.Xpp3DomBuilder.build( parser, true ) );
            }{code}
{{Xpp3DomBuilder.build(...)}} will need a variant that can track location for 
Dom elements, and we'll need to define how/where to store data
2. at model merge time, in [{{ModelMerger}} code, line 2654 for Maven 
3.6.0|https://maven.apache.org/ref/3.6.0/maven-model/xref/org/apache/maven/model/merge/ModelMerger.html#L2654]
{code:java}    protected void mergeConfigurationContainer_Configuration( 
ConfigurationContainer target,
                                                              
ConfigurationContainer source, boolean sourceDominant,
                                                              Map<Object, 
Object> context )
    {
        Xpp3Dom src = (Xpp3Dom) source.getConfiguration();
        if ( src != null )
        {
            Xpp3Dom tgt = (Xpp3Dom) target.getConfiguration();
            if ( sourceDominant || tgt == null )
            {
                tgt = Xpp3Dom.mergeXpp3Dom( new Xpp3Dom( src ), tgt );
            }
            else
            {
                tgt = Xpp3Dom.mergeXpp3Dom( tgt, src );
            }
            target.setConfiguration( tgt );
        }
    }{code}
location will require to be merged while merging Dom content

> add source location in comments to effective pom.xml
> ----------------------------------------------------
>
>                 Key: MPH-160
>                 URL: https://issues.apache.org/jira/browse/MPH-160
>             Project: Maven Help Plugin
>          Issue Type: New Feature
>          Components: effective-pom
>    Affects Versions: 3.1.0
>            Reporter: Hervé Boutemy
>            Priority: Major
>
> during in-memory effective pom building (by maven-model-builder), the source 
> location of content is kept in memory: see [Modello documentation on location 
> tracking|https://codehaus-plexus.github.io/modello/location-tracking.html] 
> and MNG-1803 for its integration into Maven model
> adding this information as comment on every line of generated XML would ease 
> tracking for end users (and not only m2e users, who get "Jump to location" 
> hint when editing their pom.xml in Eclipse...)
> This will require a Modello enhancement (see [Modello 
> #28|https://github.com/codehaus-plexus/modello/issues/28]) then integration
> (idea found during Devoxx 2018 Maven BoF, since users were missing ways to 
> diagnose unexpected result in effective pom)
> Sample result is the addition of comments with modelId and "line xxx" at the 
> end of each line of generated XML:
> {code:xml}$ mvn -Dverbose 
> org.apache.maven.plugins:maven-help-plugin:3.1.2-SNAPSHOT:effective-pom
> [INFO] Scanning for projects...
> [INFO] 
> [INFO] -------------< org.apache.maven.plugins:maven-help-plugin 
> >-------------
> [INFO] Building Apache Maven Help Plugin 3.1.2-SNAPSHOT
> [INFO] ----------------------------[ maven-plugin 
> ]----------------------------
> [INFO] 
> [INFO] --- maven-help-plugin:3.1.2-SNAPSHOT:effective-pom (default-cli) @ 
> maven-help-plugin ---
> [INFO] 
> Effective POMs, after inheritance, interpolation, and profiles are applied:
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- ====================================================================== 
> -->
> <!--                                                                        
> -->
> <!-- Generated by Maven Help Plugin on 2019-02-15T12:52:00+01:00            
> -->
> <!-- See: http://maven.apache.org/plugins/maven-help-plugin/                
> -->
> <!--                                                                        
> -->
> <!-- ====================================================================== 
> -->
> <!-- ====================================================================== 
> -->
> <!--                                                                        
> -->
> <!-- Effective POM for project                                              
> -->
> <!-- 'org.apache.maven.plugins:maven-help-plugin:maven-plugin:3.1.2-SNAPSHOT' 
> -->
> <!--                                                                        
> -->
> <!-- ====================================================================== 
> -->
> <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>  <!-- 
> org.apache.maven.plugins:maven-help-plugin:3.1.2-SNAPSHOT, line 23 -->
>   <parent>
>     <artifactId>maven-plugins</artifactId>  <!-- 
> org.apache.maven.plugins:maven-help-plugin:3.1.2-SNAPSHOT, line 26 -->
>     <groupId>org.apache.maven.plugins</groupId>  <!-- 
> org.apache.maven.plugins:maven-help-plugin:3.1.2-SNAPSHOT, line 27 -->
>     <version>33</version>  <!-- 
> org.apache.maven.plugins:maven-help-plugin:3.1.2-SNAPSHOT, line 28 -->
>     <relativePath>../../pom/maven/maven-plugins/pom.xml</relativePath>  <!-- 
> org.apache.maven.plugins:maven-help-plugin:3.1.2-SNAPSHOT, line 29 -->
>   </parent>
>   <groupId>org.apache.maven.plugins</groupId>  <!-- 
> org.apache.maven.plugins:maven-plugins:[unknown-version] 
> /home/herve/.m2/repository/org/apache/maven/plugins/maven-plugins/33/maven-plugins-33.pom,
>  line 31 -->
>   <artifactId>maven-help-plugin</artifactId>  <!-- 
> org.apache.maven.plugins:maven-help-plugin:3.1.2-SNAPSHOT, line 32 -->
>   <version>3.1.2-SNAPSHOT</version>  <!-- 
> org.apache.maven.plugins:maven-help-plugin:3.1.2-SNAPSHOT, line 33 -->
>   <packaging>maven-plugin</packaging>  <!-- 
> org.apache.maven.plugins:maven-help-plugin:3.1.2-SNAPSHOT, line 34 -->
>   <name>Apache Maven Help Plugin</name>  <!-- 
> org.apache.maven.plugins:maven-help-plugin:3.1.2-SNAPSHOT, line 36 -->
>   <description>The Maven Help plugin provides goals aimed at helping to make 
> sense out of
>     the build environment. It includes the ability to view the effective
>     POM and settings files, after inheritance and active profiles
>     have been applied, as well as a describe a particular plugin goal to give 
> usage information.</description>  <!-- 
> org.apache.maven.plugins:maven-help-plugin:3.1.2-SNAPSHOT, line 37 -->
>   <url>https://maven.apache.org/plugins/maven-help-plugin/</url>  <!-- 
> org.apache.maven.plugins:maven-plugins:[unknown-version] 
> /home/herve/.m2/repository/org/apache/maven/plugins/maven-plugins/33/maven-plugins-33.pom,
>  line 37 -->
>   <inceptionYear>2001</inceptionYear>  <!-- 
> org.apache.maven.plugins:maven-help-plugin:3.1.2-SNAPSHOT, line 43 -->
>   <organization>
>     <name>The Apache Software Foundation</name>  <!-- org.apache:apache:21, 
> line 41 -->
>     <url>https://www.apache.org/</url>  <!-- org.apache:apache:21, line 42 -->
>   </organization>
>   <licenses>
>     <license>
>       <name>Apache License, Version 2.0</name>  <!-- org.apache:apache:21, 
> line 46 -->
>       <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>  <!-- 
> org.apache:apache:21, line 47 -->
>       <distribution>repo</distribution>  <!-- org.apache:apache:21, line 48 
> -->
>     </license>
>   </licenses>
> ...{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to