Coverage Report - org.apache.maven.plugin.CompilationFailureException
 
Classes in this File Line Coverage Branch Coverage Complexity
CompilationFailureException
0%
0/15
0%
0/6
0
 
 1  
 package org.apache.maven.plugin;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.codehaus.plexus.compiler.CompilerError;
 23  
 
 24  
 import java.util.List;
 25  
 
 26  
 /**
 27  
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
 28  
  * @version $Id$
 29  
  * @since 2.0
 30  
  */
 31  
 @SuppressWarnings( "serial" )
 32  
 public class CompilationFailureException
 33  
     extends MojoFailureException
 34  
 {
 35  0
     private static final String LS = System.getProperty( "line.separator" );
 36  
 
 37  
     public CompilationFailureException( List<CompilerError> messages )
 38  
     {
 39  0
         super( null, shortMessage( messages ), longMessage( messages ) );
 40  0
     }
 41  
 
 42  
     public static String longMessage( List<CompilerError> messages )
 43  
     {
 44  0
         StringBuffer sb = new StringBuffer();
 45  
 
 46  0
         if ( messages != null )
 47  
         {
 48  0
             for ( CompilerError compilerError : messages )
 49  
             {
 50  0
                 sb.append( compilerError ).append( LS );
 51  
             }
 52  
         }
 53  0
         return sb.toString();
 54  
     }
 55  
 
 56  
     /**
 57  
      * Short message will have the error message if there's only one, useful for errors forking the compiler
 58  
      *
 59  
      * @param messages
 60  
      * @return the short error message
 61  
      * @since 2.0.2
 62  
      */
 63  
     public static String shortMessage( List<CompilerError> messages )
 64  
     {
 65  0
         StringBuffer sb = new StringBuffer();
 66  
 
 67  0
         sb.append( "Compilation failure" );
 68  
 
 69  0
         if ( messages.size() == 1 )
 70  
         {
 71  0
             sb.append( LS );
 72  
 
 73  0
             CompilerError compilerError = (CompilerError) messages.get( 0 );
 74  
 
 75  0
             sb.append( compilerError ).append( LS );
 76  
         }
 77  
         
 78  0
         return sb.toString();
 79  
     }
 80  
 }