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