View Javadoc

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   * 
15   *         
16   *         The <code>&lt;build&gt;</code> element contains
17   * informations required to build the project.
18   *         
19   *       
20   * 
21   * @version $Revision$ $Date$
22   */
23  public class Build extends BuildBase 
24  implements java.io.Serializable
25  {
26  
27  
28        //--------------------------/
29       //- Class/Member Variables -/
30      //--------------------------/
31  
32      /**
33       * This element specifies a directory containing the source of
34       * the project. The
35       *             generated build system will compile the source
36       * in this directory when the project is
37       *             built. The path given is relative to the project
38       * descriptor.
39       */
40      private String sourceDirectory;
41  
42      /**
43       * This element specifies a directory containing the script
44       * sources of the
45       *             project. This directory is meant to be different
46       * from the sourceDirectory, in that its
47       *             contents will be copied to the output directory
48       * in most cases (since scripts are
49       *             interpreted rather than compiled).
50       */
51      private String scriptSourceDirectory;
52  
53      /**
54       * This element specifies a directory containing the unit test
55       * source of the
56       *             project. The generated build system will compile
57       * these directories when the project is
58       *             being tested. The path given is relative to the
59       * project descriptor.
60       */
61      private String testSourceDirectory;
62  
63      /**
64       * The directory where compiled application classes are placed.
65       */
66      private String outputDirectory;
67  
68      /**
69       * The directory where compiled test classes are placed.
70       */
71      private String testOutputDirectory;
72  
73      /**
74       * Field extensions.
75       */
76      private java.util.List extensions;
77  
78  
79        //-----------/
80       //- Methods -/
81      //-----------/
82  
83      /**
84       * Method addExtension.
85       * 
86       * @param extension
87       */
88      public void addExtension( Extension extension )
89      {
90          if ( !(extension instanceof Extension) )
91          {
92              throw new ClassCastException( "Build.addExtensions(extension) parameter must be instanceof " + Extension.class.getName() );
93          }
94          getExtensions().add( extension );
95      } //-- void addExtension( Extension ) 
96  
97      /**
98       * Method getExtensions.
99       * 
100      * @return java.util.List
101      */
102     public java.util.List getExtensions()
103     {
104         if ( this.extensions == null )
105         {
106             this.extensions = new java.util.ArrayList();
107         }
108     
109         return this.extensions;
110     } //-- java.util.List getExtensions() 
111 
112     /**
113      * Get the directory where compiled application classes are
114      * placed.
115      * 
116      * @return String
117      */
118     public String getOutputDirectory()
119     {
120         return this.outputDirectory;
121     } //-- String getOutputDirectory() 
122 
123     /**
124      * Get this element specifies a directory containing the script
125      * sources of the
126      *             project. This directory is meant to be different
127      * from the sourceDirectory, in that its
128      *             contents will be copied to the output directory
129      * in most cases (since scripts are
130      *             interpreted rather than compiled).
131      * 
132      * @return String
133      */
134     public String getScriptSourceDirectory()
135     {
136         return this.scriptSourceDirectory;
137     } //-- String getScriptSourceDirectory() 
138 
139     /**
140      * Get this element specifies a directory containing the source
141      * of the project. The
142      *             generated build system will compile the source
143      * in this directory when the project is
144      *             built. The path given is relative to the project
145      * descriptor.
146      * 
147      * @return String
148      */
149     public String getSourceDirectory()
150     {
151         return this.sourceDirectory;
152     } //-- String getSourceDirectory() 
153 
154     /**
155      * Get the directory where compiled test classes are placed.
156      * 
157      * @return String
158      */
159     public String getTestOutputDirectory()
160     {
161         return this.testOutputDirectory;
162     } //-- String getTestOutputDirectory() 
163 
164     /**
165      * Get this element specifies a directory containing the unit
166      * test source of the
167      *             project. The generated build system will compile
168      * these directories when the project is
169      *             being tested. The path given is relative to the
170      * project descriptor.
171      * 
172      * @return String
173      */
174     public String getTestSourceDirectory()
175     {
176         return this.testSourceDirectory;
177     } //-- String getTestSourceDirectory() 
178 
179     /**
180      * Method removeExtension.
181      * 
182      * @param extension
183      */
184     public void removeExtension( Extension extension )
185     {
186         if ( !(extension instanceof Extension) )
187         {
188             throw new ClassCastException( "Build.removeExtensions(extension) parameter must be instanceof " + Extension.class.getName() );
189         }
190         getExtensions().remove( extension );
191     } //-- void removeExtension( Extension ) 
192 
193     /**
194      * Set a set of build extensions to use from this project.
195      * 
196      * @param extensions
197      */
198     public void setExtensions( java.util.List extensions )
199     {
200         this.extensions = extensions;
201     } //-- void setExtensions( java.util.List ) 
202 
203     /**
204      * Set the directory where compiled application classes are
205      * placed.
206      * 
207      * @param outputDirectory
208      */
209     public void setOutputDirectory( String outputDirectory )
210     {
211         this.outputDirectory = outputDirectory;
212     } //-- void setOutputDirectory( String ) 
213 
214     /**
215      * Set this element specifies a directory containing the script
216      * sources of the
217      *             project. This directory is meant to be different
218      * from the sourceDirectory, in that its
219      *             contents will be copied to the output directory
220      * in most cases (since scripts are
221      *             interpreted rather than compiled).
222      * 
223      * @param scriptSourceDirectory
224      */
225     public void setScriptSourceDirectory( String scriptSourceDirectory )
226     {
227         this.scriptSourceDirectory = scriptSourceDirectory;
228     } //-- void setScriptSourceDirectory( String ) 
229 
230     /**
231      * Set this element specifies a directory containing the source
232      * of the project. The
233      *             generated build system will compile the source
234      * in this directory when the project is
235      *             built. The path given is relative to the project
236      * descriptor.
237      * 
238      * @param sourceDirectory
239      */
240     public void setSourceDirectory( String sourceDirectory )
241     {
242         this.sourceDirectory = sourceDirectory;
243     } //-- void setSourceDirectory( String ) 
244 
245     /**
246      * Set the directory where compiled test classes are placed.
247      * 
248      * @param testOutputDirectory
249      */
250     public void setTestOutputDirectory( String testOutputDirectory )
251     {
252         this.testOutputDirectory = testOutputDirectory;
253     } //-- void setTestOutputDirectory( String ) 
254 
255     /**
256      * Set this element specifies a directory containing the unit
257      * test source of the
258      *             project. The generated build system will compile
259      * these directories when the project is
260      *             being tested. The path given is relative to the
261      * project descriptor.
262      * 
263      * @param testSourceDirectory
264      */
265     public void setTestSourceDirectory( String testSourceDirectory )
266     {
267         this.testSourceDirectory = testSourceDirectory;
268     } //-- void setTestSourceDirectory( String ) 
269 
270 
271     private String modelEncoding = "UTF-8";
272 
273     /**
274      * Set an encoding used for reading/writing the model.
275      *
276      * @param modelEncoding the encoding used when reading/writing the model.
277      */
278     public void setModelEncoding( String modelEncoding )
279     {
280         this.modelEncoding = modelEncoding;
281     }
282 
283     /**
284      * @return the current encoding used when reading/writing this model.
285      */
286     public String getModelEncoding()
287     {
288         return modelEncoding;
289     }
290 }