1 /*
2 * $Id$
3 */
4
5 package org.apache.maven.model;
6
7 //---------------------------------/
8 //- Imported classes and packages -/
9 //---------------------------------/
10
11 import java.util.Date;
12
13 /**
14 * Generic informations for a build.
15 *
16 * @version $Revision$ $Date$
17 */
18 public class BuildBase extends PluginConfiguration
19 implements java.io.Serializable
20 {
21
22
23 //--------------------------/
24 //- Class/Member Variables -/
25 //--------------------------/
26
27 /**
28 * The default goal (or phase in Maven 2) to execute when none
29 * is specified for
30 * the project.
31 */
32 private String defaultGoal;
33
34 /**
35 * Field resources.
36 */
37 private java.util.List resources;
38
39 /**
40 * Field testResources.
41 */
42 private java.util.List testResources;
43
44 /**
45 * The directory where all files generated by the build are
46 * placed.
47 */
48 private String directory;
49
50 /**
51 *
52 *
53 * The filename (excluding the extension, and with
54 * no path information) that
55 * the produced artifact will be called.
56 * The default value is
57 * <code>${artifactId}-${version}</code>.
58 *
59 *
60 */
61 private String finalName;
62
63 /**
64 * Field filters.
65 */
66 private java.util.List filters;
67
68
69 //-----------/
70 //- Methods -/
71 //-----------/
72
73 /**
74 * Method addFilter.
75 *
76 * @param string
77 */
78 public void addFilter( String string )
79 {
80 if ( !(string instanceof String) )
81 {
82 throw new ClassCastException( "BuildBase.addFilters(string) parameter must be instanceof " + String.class.getName() );
83 }
84 getFilters().add( string );
85 } //-- void addFilter( String )
86
87 /**
88 * Method addResource.
89 *
90 * @param resource
91 */
92 public void addResource( Resource resource )
93 {
94 if ( !(resource instanceof Resource) )
95 {
96 throw new ClassCastException( "BuildBase.addResources(resource) parameter must be instanceof " + Resource.class.getName() );
97 }
98 getResources().add( resource );
99 } //-- void addResource( Resource )
100
101 /**
102 * Method addTestResource.
103 *
104 * @param resource
105 */
106 public void addTestResource( Resource resource )
107 {
108 if ( !(resource instanceof Resource) )
109 {
110 throw new ClassCastException( "BuildBase.addTestResources(resource) parameter must be instanceof " + Resource.class.getName() );
111 }
112 getTestResources().add( resource );
113 } //-- void addTestResource( Resource )
114
115 /**
116 * Get the default goal (or phase in Maven 2) to execute when
117 * none is specified for
118 * the project.
119 *
120 * @return String
121 */
122 public String getDefaultGoal()
123 {
124 return this.defaultGoal;
125 } //-- String getDefaultGoal()
126
127 /**
128 * Get the directory where all files generated by the build are
129 * placed.
130 *
131 * @return String
132 */
133 public String getDirectory()
134 {
135 return this.directory;
136 } //-- String getDirectory()
137
138 /**
139 * Method getFilters.
140 *
141 * @return java.util.List
142 */
143 public java.util.List getFilters()
144 {
145 if ( this.filters == null )
146 {
147 this.filters = new java.util.ArrayList();
148 }
149
150 return this.filters;
151 } //-- java.util.List getFilters()
152
153 /**
154 * Get
155 *
156 * The filename (excluding the extension, and with
157 * no path information) that
158 * the produced artifact will be called.
159 * The default value is
160 * <code>${artifactId}-${version}</code>.
161 *
162 *
163 *
164 * @return String
165 */
166 public String getFinalName()
167 {
168 return this.finalName;
169 } //-- String getFinalName()
170
171 /**
172 * Method getResources.
173 *
174 * @return java.util.List
175 */
176 public java.util.List getResources()
177 {
178 if ( this.resources == null )
179 {
180 this.resources = new java.util.ArrayList();
181 }
182
183 return this.resources;
184 } //-- java.util.List getResources()
185
186 /**
187 * Method getTestResources.
188 *
189 * @return java.util.List
190 */
191 public java.util.List getTestResources()
192 {
193 if ( this.testResources == null )
194 {
195 this.testResources = new java.util.ArrayList();
196 }
197
198 return this.testResources;
199 } //-- java.util.List getTestResources()
200
201 /**
202 * Method removeFilter.
203 *
204 * @param string
205 */
206 public void removeFilter( String string )
207 {
208 if ( !(string instanceof String) )
209 {
210 throw new ClassCastException( "BuildBase.removeFilters(string) parameter must be instanceof " + String.class.getName() );
211 }
212 getFilters().remove( string );
213 } //-- void removeFilter( String )
214
215 /**
216 * Method removeResource.
217 *
218 * @param resource
219 */
220 public void removeResource( Resource resource )
221 {
222 if ( !(resource instanceof Resource) )
223 {
224 throw new ClassCastException( "BuildBase.removeResources(resource) parameter must be instanceof " + Resource.class.getName() );
225 }
226 getResources().remove( resource );
227 } //-- void removeResource( Resource )
228
229 /**
230 * Method removeTestResource.
231 *
232 * @param resource
233 */
234 public void removeTestResource( Resource resource )
235 {
236 if ( !(resource instanceof Resource) )
237 {
238 throw new ClassCastException( "BuildBase.removeTestResources(resource) parameter must be instanceof " + Resource.class.getName() );
239 }
240 getTestResources().remove( resource );
241 } //-- void removeTestResource( Resource )
242
243 /**
244 * Set the default goal (or phase in Maven 2) to execute when
245 * none is specified for
246 * the project.
247 *
248 * @param defaultGoal
249 */
250 public void setDefaultGoal( String defaultGoal )
251 {
252 this.defaultGoal = defaultGoal;
253 } //-- void setDefaultGoal( String )
254
255 /**
256 * Set the directory where all files generated by the build are
257 * placed.
258 *
259 * @param directory
260 */
261 public void setDirectory( String directory )
262 {
263 this.directory = directory;
264 } //-- void setDirectory( String )
265
266 /**
267 * Set the list of filter properties files that are used when
268 * filtering is enabled.
269 *
270 * @param filters
271 */
272 public void setFilters( java.util.List filters )
273 {
274 this.filters = filters;
275 } //-- void setFilters( java.util.List )
276
277 /**
278 * Set
279 *
280 * The filename (excluding the extension, and with
281 * no path information) that
282 * the produced artifact will be called.
283 * The default value is
284 * <code>${artifactId}-${version}</code>.
285 *
286 *
287 *
288 * @param finalName
289 */
290 public void setFinalName( String finalName )
291 {
292 this.finalName = finalName;
293 } //-- void setFinalName( String )
294
295 /**
296 * Set this element describes all of the classpath resources
297 * such as properties
298 * files associated with a project. These resources
299 * are often included in the final
300 * package.
301 *
302 * @param resources
303 */
304 public void setResources( java.util.List resources )
305 {
306 this.resources = resources;
307 } //-- void setResources( java.util.List )
308
309 /**
310 * Set this element describes all of the classpath resources
311 * such as properties
312 * files associated with a project's unit tests.
313 *
314 * @param testResources
315 */
316 public void setTestResources( java.util.List testResources )
317 {
318 this.testResources = testResources;
319 } //-- void setTestResources( java.util.List )
320
321
322 private String modelEncoding = "UTF-8";
323
324 /**
325 * Set an encoding used for reading/writing the model.
326 *
327 * @param modelEncoding the encoding used when reading/writing the model.
328 */
329 public void setModelEncoding( String modelEncoding )
330 {
331 this.modelEncoding = modelEncoding;
332 }
333
334 /**
335 * @return the current encoding used when reading/writing this model.
336 */
337 public String getModelEncoding()
338 {
339 return modelEncoding;
340 }
341 }