You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2022/09/02 07:44:00 UTC
[maven-javadoc-plugin] branch master updated: [MJAVADOC-721] Parse stderr output and suppress informational lines
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 139af8ce [MJAVADOC-721] Parse stderr output and suppress informational lines
139af8ce is described below
commit 139af8ceaedd88d59431575eff21d859ee1548c3
Author: Markus Spann <Ma...@baaderbank.de>
AuthorDate: Tue Jul 26 16:12:37 2022 +0200
[MJAVADOC-721] Parse stderr output and suppress informational lines
This closes #157
---
.../maven/plugins/javadoc/AbstractJavadocMojo.java | 56 +++++++++++++++++++++-
1 file changed, 54 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
index 543c4000..21f2ed7b 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -6081,7 +6081,25 @@ public abstract class AbstractJavadocMojo
msg.append( exitCode );
if ( StringUtils.isNotEmpty( err.getOutput() ) )
{
- msg.append( " - " ).append( err.getOutput() );
+ // parse stderr, log informational output, add all other to exception message
+ List<String> nonInfoLines = new ArrayList<>();
+ for ( String str : err.getOutput().split( "\\R" ) )
+ {
+ if ( isInformationalOutput( str ) )
+ {
+ getLog().debug( str );
+ }
+ else
+ {
+ nonInfoLines.add( str );
+ }
+ }
+ if ( !nonInfoLines.isEmpty() )
+ {
+ msg.append( '\n' ); // new line between exit code and warnings/errors
+ msg.append( String.join( "\n" , nonInfoLines ) );
+ }
+
}
msg.append( '\n' );
msg.append( "Command line was: " ).append( cmdLine ).append( '\n' ).append( '\n' );
@@ -6117,7 +6135,16 @@ public abstract class AbstractJavadocMojo
{
String current = token.nextToken().trim();
- getLog().warn( current );
+ // log informational output at debug level only
+ if ( isInformationalOutput( current ) )
+ {
+ getLog().debug( current );
+ }
+ else
+ {
+ getLog().warn( current );
+ }
+
}
}
@@ -6144,6 +6171,31 @@ public abstract class AbstractJavadocMojo
}
}
+ /**
+ * Determines whether the specified string is informational output of the Javadoc tool.<br/>
+ * Such output should not be included as exception message or logged as warning or error.
+ * <p>
+ * The following texts are either hardcoded in the tool or can be found in versions of the
+ * javadoc tool's English resource bundle of JDK 11 (and presumably later versions).<br/>
+ * This method will neither help nor harm for localized (non-English) versions of the tool.
+ * </p>
+ *
+ * @param str string to check
+ * @return true if informational output, false if not or cannot be determined
+ */
+ private boolean isInformationalOutput( String str )
+ {
+ return str == null
+ || str.trim().isEmpty()
+ || str.startsWith( "Loading source files for package " ) // main.Loading_source_files_for_package
+ || str.startsWith( "Loading source file " ) // main.Loading_source_file
+ || str.startsWith( "Generating " )
+ || str.startsWith( "Constructing Javadoc information" ) // main.Building_tree
+ || str.startsWith( "Building index for " )
+ || str.startsWith( "Building tree for " )
+ || str.startsWith( "Standard Doclet version " );
+ }
+
/**
* Patches the given Javadoc output directory to work around CVE-2013-1571
* (see http://www.kb.cert.org/vuls/id/225657).