You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ca...@apache.org on 2007/01/11 19:50:33 UTC
svn commit: r495329 -
/maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilationFailureException.java
Author: carlos
Date: Thu Jan 11 10:50:32 2007
New Revision: 495329
URL: http://svn.apache.org/viewvc?view=rev&rev=495329
Log:
Improve error message when forking and only one error happens
Modified:
maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilationFailureException.java
Modified: maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilationFailureException.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilationFailureException.java?view=diff&rev=495329&r1=495328&r2=495329
==============================================================================
--- maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilationFailureException.java (original)
+++ maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilationFailureException.java Thu Jan 11 10:50:32 2007
@@ -1,7 +1,7 @@
package org.apache.maven.plugin;
/*
- * Copyright 2001-2005 The Apache Software Foundation.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,11 +16,11 @@
* limitations under the License.
*/
-import org.codehaus.plexus.compiler.CompilerError;
-
import java.util.Iterator;
import java.util.List;
+import org.codehaus.plexus.compiler.CompilerError;
+
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
@@ -32,7 +32,7 @@
public CompilationFailureException( List messages )
{
- super( null, "Compilation failure", longMessage( messages ) );
+ super( null, shortMessage( messages ), longMessage( messages ) );
}
public static String longMessage( List messages )
@@ -42,6 +42,28 @@
for ( Iterator it = messages.iterator(); it.hasNext(); )
{
CompilerError compilerError = (CompilerError) it.next();
+
+ 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
+ * @return the short error message
+ */
+ public static String shortMessage( List messages )
+ {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append( "Compilation failure" );
+
+ if ( messages.size() == 1 )
+ {
+ sb.append( LS );
+
+ CompilerError compilerError = (CompilerError) messages.get( 0 );
sb.append( compilerError ).append( LS );
}