You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2019/08/02 19:11:26 UTC
[maven-compiler-plugin] branch master updated: Simplify
CompilationFailureException
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 942fe42 Simplify CompilationFailureException
942fe42 is described below
commit 942fe427d22e1ce6125aa8465be3b6e5fc584469
Author: Russell Howe <rh...@siksai.co.uk>
AuthorDate: Fri Aug 2 20:11:21 2019 +0100
Simplify CompilationFailureException
---
.../compiler/CompilationFailureException.java | 33 +++++++++++++---------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugin/compiler/CompilationFailureException.java b/src/main/java/org/apache/maven/plugin/compiler/CompilationFailureException.java
index b231c8e..4d62454 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/CompilationFailureException.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/CompilationFailureException.java
@@ -34,45 +34,50 @@ public class CompilationFailureException
{
private static final String LS = System.getProperty( "line.separator" );
+ /**
+ * Wrap error messages from the compiler
+ *
+ * @param messages the messages, not null
+ * @since 2.0
+ */
public CompilationFailureException( List<CompilerMessage> messages )
{
super( null, shortMessage( messages ), longMessage( messages ) );
}
+ /**
+ * Long message will have all messages, one per line
+ *
+ * @param messages the messages, not null
+ * @return the long error message
+ * @since 2.0
+ */
public static String longMessage( List<CompilerMessage> messages )
{
StringBuilder sb = new StringBuilder();
- if ( messages != null )
+ for ( CompilerMessage compilerError : messages )
{
- for ( CompilerMessage compilerError : messages )
- {
- sb.append( compilerError ).append( LS );
- }
+ sb.append( compilerError ).append( LS );
}
+
return sb.toString();
}
/**
* Short message will have the error message if there's only one, useful for errors forking the compiler
*
- * @param messages the messages
+ * @param messages the messages, not null
* @return the short error message
* @since 2.0.2
*/
public static String shortMessage( List<CompilerMessage> messages )
{
- StringBuilder sb = new StringBuilder();
-
- sb.append( "Compilation failure" );
+ StringBuilder sb = new StringBuilder( "Compilation failure" );
if ( messages.size() == 1 )
{
- sb.append( LS );
-
- CompilerMessage compilerError = messages.get( 0 );
-
- sb.append( compilerError ).append( LS );
+ sb.append( LS ).append( messages.get( 0 ) ).append( LS );
}
return sb.toString();