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