1 package org.apache.maven.lifecycle;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
23
24 import org.apache.maven.plugin.MojoExecution;
25 import org.apache.maven.project.MavenProject;
26 import org.apache.maven.shared.utils.logging.MessageBuilder;
27
28
29
30
31 public class LifecycleExecutionException
32 extends Exception
33 {
34 private MavenProject project;
35
36 public LifecycleExecutionException( String message )
37 {
38 super( message );
39 }
40
41 public LifecycleExecutionException( Throwable cause )
42 {
43 super( cause );
44 }
45
46 public LifecycleExecutionException( String message, Throwable cause )
47 {
48 super( message, cause );
49 }
50
51 public LifecycleExecutionException( String message, MavenProject project )
52 {
53 super( message );
54 this.project = project;
55 }
56
57 public LifecycleExecutionException( String message, MojoExecution execution, MavenProject project )
58 {
59 super( message );
60 this.project = project;
61 }
62
63 public LifecycleExecutionException( String message, MojoExecution execution, MavenProject project, Throwable cause )
64 {
65 super( message, cause );
66 this.project = project;
67 }
68
69 public LifecycleExecutionException( MojoExecution execution, MavenProject project, Throwable cause )
70 {
71 this( createMessage( execution, project, cause ), execution, project, cause );
72 }
73
74 public MavenProject getProject()
75 {
76 return project;
77 }
78
79 private static String createMessage( MojoExecution execution, MavenProject project, Throwable cause )
80 {
81 MessageBuilder buffer = buffer( 256 );
82
83 buffer.a( "Failed to execute goal" );
84
85 if ( execution != null )
86 {
87 buffer.a( ' ' );
88 buffer.mojo( execution.getGroupId() + ':' + execution.getArtifactId() + ':' + execution.getVersion() + ':'
89 + execution.getGoal() );
90 buffer.a( ' ' ).strong( '(' + execution.getExecutionId() + ')' );
91 }
92
93 if ( project != null )
94 {
95 buffer.a( " on project " );
96 buffer.project( project.getArtifactId() );
97 }
98
99 if ( cause != null )
100 {
101 buffer.a( ": " ).failure( cause.getMessage() );
102 }
103
104 return buffer.toString();
105 }
106
107 }