michael-o 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_r386394314
##########
File path:
maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
##########
@@ -1043,6 +1115,120 @@ private String findProfilesXml( ModelBuildingResult
result, Map<File, Boolean> p
return null;
}
+
+ private Collection<FileTransformer> getTransformersForArtifact( final
org.eclipse.aether.artifact.Artifact artifact,
+
TransformerContext context )
+ {
+ Collection<FileTransformer> transformers = new ArrayList<>();
+ if ( "pom".equals( artifact.getExtension() ) )
+ {
+ final SAXTransformerFactory transformerFactory =
+ (SAXTransformerFactory) Factories.newTransformerFactory();
+
+ transformers.add( new FileTransformer()
+ {
+ @Override
+ public InputStream transformData( File file )
+ throws IOException, TransformException
+ {
+ final PipedOutputStream pipedOutputStream = new
PipedOutputStream();
+ final PipedInputStream pipedInputStream = new
PipedInputStream( pipedOutputStream );
+
+ final TransformerHandler transformerHandler =
+ getTransformerHandler( transformerFactory, file );
+
+ BuildPomXMLFilterFactory buildPomXmlFactory = new
DefaultBuildPomXMLFilterFactory( context );
+
+ final SAXSource transformSource;
+ try
+ {
+ AbstractSAXFilter filter =
+ new ConsumerPomXMLFilterFactory(
buildPomXmlFactory ).get( file.toPath() );
+ filter.setLexicalHandler( transformerHandler );
+
+ transformSource =
+ new SAXSource( filter, new InputSource( new
FileInputStream( file ) ) );
+ }
+ catch ( SAXException | ParserConfigurationException |
TransformerConfigurationException e )
+ {
+ throw new TransformException( "Failed to create a
consumerPomXMLFilter", e );
+ }
+
+ transformerHandler.setResult( new StreamResult(
pipedOutputStream ) );
+
+ SAXResult transformResult = new SAXResult(
transformerHandler );
+
+ ExecutorService executorService =
Executors.newSingleThreadExecutor();
+ executorService.execute( () ->
Review comment:
What is the reason to run this async? Who is receiving this
`pipedInputStream`?
----------------------------------------------------------------
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