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 org.apache.maven.plugin.MojoExecution;
23 import org.apache.maven.project.MavenProject;
24
25
26
27
28
29 public class LifecycleExecutionException
30 extends Exception
31 {
32 private MavenProject project;
33
34 public LifecycleExecutionException( String message )
35 {
36 super( message );
37 }
38
39 public LifecycleExecutionException( Throwable cause )
40 {
41 super( cause );
42 }
43
44 public LifecycleExecutionException( String message, Throwable cause )
45 {
46 super( message, cause );
47 }
48
49 public LifecycleExecutionException( String message, MavenProject project )
50 {
51 super( message );
52 this.project = project;
53 }
54
55 public LifecycleExecutionException( String message, MojoExecution execution, MavenProject project )
56 {
57 super( message );
58 this.project = project;
59 }
60
61 public LifecycleExecutionException( String message, MojoExecution execution, MavenProject project, Throwable cause )
62 {
63 super( message, cause );
64 this.project = project;
65 }
66
67 public LifecycleExecutionException( MojoExecution execution, MavenProject project, Throwable cause )
68 {
69 this( createMessage( execution, project, cause ), execution, project, cause );
70 }
71
72 public MavenProject getProject()
73 {
74 return project;
75 }
76
77 private static String createMessage( MojoExecution execution, MavenProject project, Throwable cause )
78 {
79 StringBuilder buffer = new StringBuilder( 256 );
80
81 buffer.append( "Failed to execute goal" );
82
83 if ( execution != null )
84 {
85 buffer.append( ' ' );
86 buffer.append( execution.getGroupId() );
87 buffer.append( ':' );
88 buffer.append( execution.getArtifactId() );
89 buffer.append( ':' );
90 buffer.append( execution.getVersion() );
91 buffer.append( ':' );
92 buffer.append( execution.getGoal() );
93 buffer.append( " (" );
94 buffer.append( execution.getExecutionId() );
95 buffer.append( ")" );
96 }
97
98 if ( project != null )
99 {
100 buffer.append( " on project " );
101 buffer.append( project.getArtifactId() );
102 }
103
104 if ( cause != null )
105 {
106 buffer.append( ": " ).append( cause.getMessage() );
107 }
108
109 return buffer.toString();
110 }
111
112 }