1 package org.apache.maven.project;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.List;
24
25
26
27
28 public class ProjectBuildingException
29 extends Exception
30 {
31 private final String projectId;
32
33 private File pomFile;
34
35 private List<ProjectBuildingResult> results;
36
37 public ProjectBuildingException( String projectId, String message, Throwable cause )
38 {
39 super( createMessage( message, projectId, null ), cause );
40 this.projectId = projectId;
41 }
42
43
44
45
46
47
48 public ProjectBuildingException( String projectId, String message, File pomFile )
49 {
50 super( createMessage( message, projectId, pomFile ) );
51 this.projectId = projectId;
52 this.pomFile = pomFile;
53 }
54
55
56
57
58
59
60
61 protected ProjectBuildingException( String projectId, String message, File pomFile, Throwable cause )
62 {
63 super( createMessage( message, projectId, pomFile ), cause );
64 this.projectId = projectId;
65 this.pomFile = pomFile;
66 }
67
68 public ProjectBuildingException( List<ProjectBuildingResult> results )
69 {
70 super( "Some problems were encountered while processing the POMs" );
71 this.projectId = "";
72 this.results = results;
73 }
74
75 public File getPomFile()
76 {
77 return pomFile;
78 }
79
80
81
82
83 public String getPomLocation()
84 {
85 if ( getPomFile() != null )
86 {
87 return getPomFile().getAbsolutePath();
88 }
89 else
90 {
91 return "null";
92 }
93 }
94
95 public String getProjectId()
96 {
97 return projectId;
98 }
99
100 public List<ProjectBuildingResult> getResults()
101 {
102 return results;
103 }
104
105 private static String createMessage( String message, String projectId, File pomFile )
106 {
107 StringBuilder buffer = new StringBuilder( 256 );
108 buffer.append( message );
109 buffer.append( " for project " ).append( projectId );
110 if ( pomFile != null )
111 {
112 buffer.append( " at " ).append( pomFile.getAbsolutePath() );
113 }
114 return buffer.toString();
115 }
116
117 }