1 package org.apache.maven.plugin;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.codehaus.plexus.compiler.CompilerError;
23
24 import java.util.Iterator;
25 import java.util.List;
26
27
28
29
30
31
32 public class CompilationFailureException
33 extends MojoFailureException
34 {
35 private static final String LS = System.getProperty( "line.separator" );
36
37 public CompilationFailureException( List messages )
38 {
39 super( null, shortMessage( messages ), longMessage( messages ) );
40 }
41
42 public static String longMessage( List messages )
43 {
44 StringBuffer sb = new StringBuffer();
45
46 for ( Iterator it = messages.iterator(); it.hasNext(); )
47 {
48 CompilerError compilerError = (CompilerError) it.next();
49
50 sb.append( compilerError ).append( LS );
51 }
52 return sb.toString();
53 }
54
55
56
57
58
59
60
61
62 public static String shortMessage( List messages )
63 {
64 StringBuffer sb = new StringBuffer();
65
66 sb.append( "Compilation failure" );
67
68 if ( messages.size() == 1 )
69 {
70 sb.append( LS );
71
72 CompilerError compilerError = (CompilerError) messages.get( 0 );
73
74 sb.append( compilerError ).append( LS );
75 }
76
77 return sb.toString();
78 }
79 }