mthmulders commented on code in PR #76:
URL: https://github.com/apache/maven-help-plugin/pull/76#discussion_r1008690718
##########
src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java:
##########
@@ -140,24 +161,73 @@ public void execute()
}
String effectivePom = prettyFormat( w.toString(), encoding, false );
+ effectivePom = prettyFormatVerbose( effectivePom );
+ reportEffectivePom( effectivePom, output );
+ }
+
+ private void generateIndividualEffectivePom() throws MojoExecutionException
+ {
+ String encoding = project.getModel().getModelEncoding();
+ if ( shouldWriteAllEffectivePOMsInReactor() )
+ {
+ // outer root element
+ for ( MavenProject subProject : projects )
+ {
+ StringWriter w = new StringWriter();
+ XMLWriter writer =
+ getPrettyPrintXMLWriterForEffectivePom( w, encoding );
+ writeHeader( writer );
+ writeEffectivePom( subProject, writer );
+ String effectivePom = prettyFormat( w.toString(), encoding,
false );
+ effectivePom = prettyFormatVerbose( effectivePom );
+ File effectiveOutput = new File(
subProject.getBuild().getDirectory() + "/effective.pom.xml" );
+ reportEffectivePom( effectivePom, effectiveOutput );
+ }
+ }
+ else
+ {
+ StringWriter w = new StringWriter();
+ XMLWriter writer =
+ getPrettyPrintXMLWriterForEffectivePom( w, encoding );
+ writeHeader( writer );
+ writeEffectivePom( project, writer );
+ String effectivePom = prettyFormat( w.toString(), encoding, false
);
+ effectivePom = prettyFormatVerbose( effectivePom );
+ File effectiveOutput = new File( project.getBuild().getDirectory()
+ "/effective.pom.xml" );
+ reportEffectivePom( effectivePom, effectiveOutput );
+ }
+ }
+
+ private String prettyFormatVerbose( String effectivePom )
+ {
if ( verbose )
{
// tweak location tracking comment, that are put on a separate
line by pretty print
effectivePom = effectivePom.replaceAll( "(?m)>\\s+<!--}", "> <!--
" );
}
+ return effectivePom;
+ }
+
+ private PrettyPrintXMLWriter getPrettyPrintXMLWriterForEffectivePom(
StringWriter w, String encoding )
+ {
+ return new PrettyPrintXMLWriter( w, StringUtils.repeat( " ",
XmlWriterUtil.DEFAULT_INDENTATION_SIZE ),
+ encoding, null );
+ }
- if ( output != null )
+ private void reportEffectivePom( String effectivePom, File effectiveOutput
) throws MojoExecutionException
+ {
+ if ( effectiveOutput != null )
{
try
{
- writeXmlFile( output, effectivePom );
+ writeXmlFile( effectiveOutput, effectivePom );
}
catch ( IOException e )
{
- throw new MojoExecutionException( "Cannot write effective-POM
to output: " + output, e );
+ throw new MojoExecutionException( "Cannot write effective-POM
to output: " + effectiveOutput, e );
Review Comment:
```suggestion
throw new MojoExecutionException( "Cannot write effective
POM to output: " + effectiveOutput, e );
```
##########
src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java:
##########
@@ -140,24 +161,73 @@ public void execute()
}
String effectivePom = prettyFormat( w.toString(), encoding, false );
+ effectivePom = prettyFormatVerbose( effectivePom );
+ reportEffectivePom( effectivePom, output );
+ }
+
+ private void generateIndividualEffectivePom() throws MojoExecutionException
+ {
+ String encoding = project.getModel().getModelEncoding();
+ if ( shouldWriteAllEffectivePOMsInReactor() )
+ {
+ // outer root element
+ for ( MavenProject subProject : projects )
+ {
+ StringWriter w = new StringWriter();
+ XMLWriter writer =
+ getPrettyPrintXMLWriterForEffectivePom( w, encoding );
+ writeHeader( writer );
+ writeEffectivePom( subProject, writer );
+ String effectivePom = prettyFormat( w.toString(), encoding,
false );
+ effectivePom = prettyFormatVerbose( effectivePom );
+ File effectiveOutput = new File(
subProject.getBuild().getDirectory() + "/effective.pom.xml" );
+ reportEffectivePom( effectivePom, effectiveOutput );
+ }
+ }
+ else
+ {
+ StringWriter w = new StringWriter();
+ XMLWriter writer =
+ getPrettyPrintXMLWriterForEffectivePom( w, encoding );
+ writeHeader( writer );
+ writeEffectivePom( project, writer );
+ String effectivePom = prettyFormat( w.toString(), encoding, false
);
+ effectivePom = prettyFormatVerbose( effectivePom );
+ File effectiveOutput = new File( project.getBuild().getDirectory()
+ "/effective.pom.xml" );
+ reportEffectivePom( effectivePom, effectiveOutput );
+ }
+ }
+
+ private String prettyFormatVerbose( String effectivePom )
+ {
if ( verbose )
{
// tweak location tracking comment, that are put on a separate
line by pretty print
effectivePom = effectivePom.replaceAll( "(?m)>\\s+<!--}", "> <!--
" );
}
+ return effectivePom;
+ }
+
+ private PrettyPrintXMLWriter getPrettyPrintXMLWriterForEffectivePom(
StringWriter w, String encoding )
+ {
+ return new PrettyPrintXMLWriter( w, StringUtils.repeat( " ",
XmlWriterUtil.DEFAULT_INDENTATION_SIZE ),
+ encoding, null );
+ }
- if ( output != null )
+ private void reportEffectivePom( String effectivePom, File effectiveOutput
) throws MojoExecutionException
+ {
+ if ( effectiveOutput != null )
{
try
{
- writeXmlFile( output, effectivePom );
+ writeXmlFile( effectiveOutput, effectivePom );
}
catch ( IOException e )
{
- throw new MojoExecutionException( "Cannot write effective-POM
to output: " + output, e );
+ throw new MojoExecutionException( "Cannot write effective-POM
to output: " + effectiveOutput, e );
}
- getLog().info( "Effective-POM written to: " + output );
+ getLog().info( "Effective-POM written to: " + effectiveOutput );
Review Comment:
```suggestion
getLog().info( "Effective POM written to: " + effectiveOutput );
```
--
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]