rfscholte commented on a change in pull request #286: [MNG-6656] Introduce base 
for build/consumer process
URL: https://github.com/apache/maven/pull/286#discussion_r330204588
 
 

 ##########
 File path: 
maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
 ##########
 @@ -733,12 +758,81 @@ private void checkPluginVersions( List<ModelData> 
lineage, ModelBuildingRequest
     private void assembleInheritance( List<ModelData> lineage, 
ModelBuildingRequest request,
                                       ModelProblemCollector problems )
     {
-        for ( int i = lineage.size() - 2; i >= 0; i-- )
+        for ( int i = lineage.size() - 2; i >= 1; i-- )
         {
             Model parent = lineage.get( i + 1 ).getModel();
             Model child = lineage.get( i ).getModel();
             inheritanceAssembler.assembleModelInheritance( child, parent, 
request, problems );
         }
+        
+        // re-read model from file
+        if ( Boolean.getBoolean( "maven.experimental.buildconsumer" ) && 
request.isTransformPom() )
+        {
+            try
+            {
+                // TODO: parent might be part of reactor... better read all 
lineage items like this?
+                Model parent = lineage.get( 1 ).getModel();
+                
+                Model child = modelProcessor.read( transformData( lineage.get( 
0 ) ), null );
+                inheritanceAssembler.assembleModelInheritance( child, parent, 
request, problems );
+
+                // sync pomfile, is transient
+                child.setPomFile( lineage.get( 0 ).getModel().getPomFile() );
+                // overwrite child
+                lineage.get( 0 ).setModel( child );
+            }
+            catch ( IOException | TransformException | SAXException | 
ParserConfigurationException e )
+            {
+                // this is second read, should not happen
+                e.printStackTrace();
+            }
+        }
+        else
+        {
+            Model parent = lineage.get( 1 ).getModel();
+            Model child = lineage.get( 0 ).getModel();
+            inheritanceAssembler.assembleModelInheritance( child, parent, 
request, problems );
+        }
+    }
+    
+    private InputStream transformData( ModelData modelData )
+                    throws IOException, TransformException, SAXException, 
ParserConfigurationException
+    {
+        final TransformerFactory transformerFactory = 
TransformerFactory.newInstance();
+        
+        final PipedOutputStream pipedOutputStream  = new PipedOutputStream();
+        final PipedInputStream pipedInputStream  = new PipedInputStream( 
pipedOutputStream );
+
+        // Should always be FileSource for reactor poms
+        FileSource source = (FileSource) modelData.getSource();
+        
+        System.out.println( "transforming " + source.getFile() );
 
 Review comment:
   Should be removed, but it exposed an interesting bug: 
https://issues.apache.org/jira/browse/MNG-6753

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to