gnodet commented on code in PR #828:
URL: https://github.com/apache/maven/pull/828#discussion_r995672029


##########
maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java:
##########
@@ -337,7 +337,7 @@ protected void mergeReporting_Plugins( Reporting.Builder 
builder,
                     if ( element.isInherited() )
                     {
                         // NOTE: Enforce recursive merge to trigger 
merging/inheritance logic for executions as well
-                        ReportPlugin plugin = ReportPlugin.newInstance();
+                        ReportPlugin plugin = ReportPlugin.newInstance( false 
);

Review Comment:
   Here's the generated code for the `newInstance()` methods:
   ```
       /**
        * Creates a new {@code ReportPlugin} instance.
        * Equivalent to {@code newInstance( true )}.
        * @see #newInstance(boolean)
        *
        * @return a new {@code ReportPlugin}
        */
       @Nonnull
       public static ReportPlugin newInstance()
       {
           return newInstance( true );
       }
   
       /**
        * Creates a new {@code ReportPlugin} instance using default values or 
not.
        * Equivalent to {@code newBuilder( withDefaults ).build()}.
        *
        * @param withDefaults the boolean indicating whether default values 
should be used
        * @return a new {@code ReportPlugin}
        */
       @Nonnull
       public static ReportPlugin newInstance( boolean withDefaults )
       {
           return newBuilder( withDefaults ).build();
       }
   ```
   
   The default values comes from the model.  By default the `groupId` has the 
value `org.apache.maven.plugins`.
   
   In the v3 model, we had [the 
following](https://github.com/apache/maven/blob/maven-3.9.x/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java#L338-L341)
 instead:
   ```
                           ReportPlugin plugin = new ReportPlugin();
                           plugin.setLocation( "", element.getLocation( "" ) );
                           plugin.setGroupId( null );
                           mergeReportPlugin( plugin, element, sourceDominant, 
context );
   ```
   The problem is that the call to `plugin.setGroupId( null )` had been missed 
during the apiv4 merge.  The use of the `newInstance( false )` forces to not 
use default values.



-- 
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]

Reply via email to