1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
package org.apache.maven.plugin.assembly.model.io.xpp3; |
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
import java.io.OutputStream; |
15 | |
import java.io.Writer; |
16 | |
import java.text.DateFormat; |
17 | |
import java.util.Iterator; |
18 | |
import java.util.Locale; |
19 | |
import org.apache.maven.plugin.assembly.model.Component; |
20 | |
import org.apache.maven.plugin.assembly.model.ContainerDescriptorHandlerConfig; |
21 | |
import org.apache.maven.plugin.assembly.model.DependencySet; |
22 | |
import org.apache.maven.plugin.assembly.model.FileItem; |
23 | |
import org.apache.maven.plugin.assembly.model.FileSet; |
24 | |
import org.apache.maven.plugin.assembly.model.GroupVersionAlignment; |
25 | |
import org.apache.maven.plugin.assembly.model.ModuleBinaries; |
26 | |
import org.apache.maven.plugin.assembly.model.ModuleSet; |
27 | |
import org.apache.maven.plugin.assembly.model.ModuleSources; |
28 | |
import org.apache.maven.plugin.assembly.model.Repository; |
29 | |
import org.apache.maven.plugin.assembly.model.UnpackOptions; |
30 | |
import org.codehaus.plexus.util.xml.Xpp3Dom; |
31 | |
import org.codehaus.plexus.util.xml.pull.MXSerializer; |
32 | |
import org.codehaus.plexus.util.xml.pull.XmlSerializer; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
@SuppressWarnings( "all" ) |
40 | 3 | public class ComponentXpp3Writer |
41 | |
{ |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | 1 | private static final String NAMESPACE = null; |
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
public void write( Writer writer, Component component ) |
65 | |
throws java.io.IOException |
66 | |
{ |
67 | 3 | XmlSerializer serializer = new MXSerializer(); |
68 | 3 | serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " ); |
69 | 3 | serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" ); |
70 | 3 | serializer.setOutput( writer ); |
71 | 3 | serializer.startDocument( component.getModelEncoding(), null ); |
72 | 3 | writeComponent( component, "component", serializer ); |
73 | 3 | serializer.endDocument(); |
74 | 3 | } |
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
public void write( OutputStream stream, Component component ) |
84 | |
throws java.io.IOException |
85 | |
{ |
86 | 0 | XmlSerializer serializer = new MXSerializer(); |
87 | 0 | serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " ); |
88 | 0 | serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" ); |
89 | 0 | serializer.setOutput( stream, component.getModelEncoding() ); |
90 | 0 | serializer.startDocument( component.getModelEncoding(), null ); |
91 | 0 | writeComponent( component, "component", serializer ); |
92 | 0 | serializer.endDocument(); |
93 | 0 | } |
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
private void writeComponent( Component component, String tagName, XmlSerializer serializer ) |
104 | |
throws java.io.IOException |
105 | |
{ |
106 | 3 | serializer.startTag( NAMESPACE, tagName ); |
107 | 3 | if ( ( component.getModuleSets() != null ) && ( component.getModuleSets().size() > 0 ) ) |
108 | |
{ |
109 | 0 | serializer.startTag( NAMESPACE, "moduleSets" ); |
110 | 0 | for ( Iterator iter = component.getModuleSets().iterator(); iter.hasNext(); ) |
111 | |
{ |
112 | 0 | ModuleSet o = (ModuleSet) iter.next(); |
113 | 0 | writeModuleSet( o, "moduleSet", serializer ); |
114 | 0 | } |
115 | 0 | serializer.endTag( NAMESPACE, "moduleSets" ); |
116 | |
} |
117 | 3 | if ( ( component.getFileSets() != null ) && ( component.getFileSets().size() > 0 ) ) |
118 | |
{ |
119 | 3 | serializer.startTag( NAMESPACE, "fileSets" ); |
120 | 3 | for ( Iterator iter = component.getFileSets().iterator(); iter.hasNext(); ) |
121 | |
{ |
122 | 3 | FileSet o = (FileSet) iter.next(); |
123 | 3 | writeFileSet( o, "fileSet", serializer ); |
124 | 3 | } |
125 | 3 | serializer.endTag( NAMESPACE, "fileSets" ); |
126 | |
} |
127 | 3 | if ( ( component.getFiles() != null ) && ( component.getFiles().size() > 0 ) ) |
128 | |
{ |
129 | 0 | serializer.startTag( NAMESPACE, "files" ); |
130 | 0 | for ( Iterator iter = component.getFiles().iterator(); iter.hasNext(); ) |
131 | |
{ |
132 | 0 | FileItem o = (FileItem) iter.next(); |
133 | 0 | writeFileItem( o, "file", serializer ); |
134 | 0 | } |
135 | 0 | serializer.endTag( NAMESPACE, "files" ); |
136 | |
} |
137 | 3 | if ( ( component.getDependencySets() != null ) && ( component.getDependencySets().size() > 0 ) ) |
138 | |
{ |
139 | 0 | serializer.startTag( NAMESPACE, "dependencySets" ); |
140 | 0 | for ( Iterator iter = component.getDependencySets().iterator(); iter.hasNext(); ) |
141 | |
{ |
142 | 0 | DependencySet o = (DependencySet) iter.next(); |
143 | 0 | writeDependencySet( o, "dependencySet", serializer ); |
144 | 0 | } |
145 | 0 | serializer.endTag( NAMESPACE, "dependencySets" ); |
146 | |
} |
147 | 3 | if ( ( component.getRepositories() != null ) && ( component.getRepositories().size() > 0 ) ) |
148 | |
{ |
149 | 0 | serializer.startTag( NAMESPACE, "repositories" ); |
150 | 0 | for ( Iterator iter = component.getRepositories().iterator(); iter.hasNext(); ) |
151 | |
{ |
152 | 0 | Repository o = (Repository) iter.next(); |
153 | 0 | writeRepository( o, "repository", serializer ); |
154 | 0 | } |
155 | 0 | serializer.endTag( NAMESPACE, "repositories" ); |
156 | |
} |
157 | 3 | if ( ( component.getContainerDescriptorHandlers() != null ) && ( component.getContainerDescriptorHandlers().size() > 0 ) ) |
158 | |
{ |
159 | 0 | serializer.startTag( NAMESPACE, "containerDescriptorHandlers" ); |
160 | 0 | for ( Iterator iter = component.getContainerDescriptorHandlers().iterator(); iter.hasNext(); ) |
161 | |
{ |
162 | 0 | ContainerDescriptorHandlerConfig o = (ContainerDescriptorHandlerConfig) iter.next(); |
163 | 0 | writeContainerDescriptorHandlerConfig( o, "containerDescriptorHandler", serializer ); |
164 | 0 | } |
165 | 0 | serializer.endTag( NAMESPACE, "containerDescriptorHandlers" ); |
166 | |
} |
167 | 3 | serializer.endTag( NAMESPACE, tagName ); |
168 | 3 | } |
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
private void writeContainerDescriptorHandlerConfig( ContainerDescriptorHandlerConfig containerDescriptorHandlerConfig, String tagName, XmlSerializer serializer ) |
179 | |
throws java.io.IOException |
180 | |
{ |
181 | 0 | serializer.startTag( NAMESPACE, tagName ); |
182 | 0 | if ( containerDescriptorHandlerConfig.getHandlerName() != null ) |
183 | |
{ |
184 | 0 | serializer.startTag( NAMESPACE, "handlerName" ).text( containerDescriptorHandlerConfig.getHandlerName() ).endTag( NAMESPACE, "handlerName" ); |
185 | |
} |
186 | 0 | if ( containerDescriptorHandlerConfig.getConfiguration() != null ) |
187 | |
{ |
188 | 0 | ((Xpp3Dom) containerDescriptorHandlerConfig.getConfiguration()).writeToSerializer( NAMESPACE, serializer ); |
189 | |
} |
190 | 0 | serializer.endTag( NAMESPACE, tagName ); |
191 | 0 | } |
192 | |
|
193 | |
|
194 | |
|
195 | |
|
196 | |
|
197 | |
|
198 | |
|
199 | |
|
200 | |
|
201 | |
private void writeDependencySet( DependencySet dependencySet, String tagName, XmlSerializer serializer ) |
202 | |
throws java.io.IOException |
203 | |
{ |
204 | 0 | serializer.startTag( NAMESPACE, tagName ); |
205 | 0 | if ( dependencySet.getOutputDirectory() != null ) |
206 | |
{ |
207 | 0 | serializer.startTag( NAMESPACE, "outputDirectory" ).text( dependencySet.getOutputDirectory() ).endTag( NAMESPACE, "outputDirectory" ); |
208 | |
} |
209 | 0 | if ( ( dependencySet.getIncludes() != null ) && ( dependencySet.getIncludes().size() > 0 ) ) |
210 | |
{ |
211 | 0 | serializer.startTag( NAMESPACE, "includes" ); |
212 | 0 | for ( Iterator iter = dependencySet.getIncludes().iterator(); iter.hasNext(); ) |
213 | |
{ |
214 | 0 | String include = (String) iter.next(); |
215 | 0 | serializer.startTag( NAMESPACE, "include" ).text( include ).endTag( NAMESPACE, "include" ); |
216 | 0 | } |
217 | 0 | serializer.endTag( NAMESPACE, "includes" ); |
218 | |
} |
219 | 0 | if ( ( dependencySet.getExcludes() != null ) && ( dependencySet.getExcludes().size() > 0 ) ) |
220 | |
{ |
221 | 0 | serializer.startTag( NAMESPACE, "excludes" ); |
222 | 0 | for ( Iterator iter = dependencySet.getExcludes().iterator(); iter.hasNext(); ) |
223 | |
{ |
224 | 0 | String exclude = (String) iter.next(); |
225 | 0 | serializer.startTag( NAMESPACE, "exclude" ).text( exclude ).endTag( NAMESPACE, "exclude" ); |
226 | 0 | } |
227 | 0 | serializer.endTag( NAMESPACE, "excludes" ); |
228 | |
} |
229 | 0 | if ( dependencySet.getFileMode() != null ) |
230 | |
{ |
231 | 0 | serializer.startTag( NAMESPACE, "fileMode" ).text( dependencySet.getFileMode() ).endTag( NAMESPACE, "fileMode" ); |
232 | |
} |
233 | 0 | if ( dependencySet.getDirectoryMode() != null ) |
234 | |
{ |
235 | 0 | serializer.startTag( NAMESPACE, "directoryMode" ).text( dependencySet.getDirectoryMode() ).endTag( NAMESPACE, "directoryMode" ); |
236 | |
} |
237 | 0 | if ( dependencySet.isUseStrictFiltering() != false ) |
238 | |
{ |
239 | 0 | serializer.startTag( NAMESPACE, "useStrictFiltering" ).text( String.valueOf( dependencySet.isUseStrictFiltering() ) ).endTag( NAMESPACE, "useStrictFiltering" ); |
240 | |
} |
241 | 0 | if ( ( dependencySet.getOutputFileNameMapping() != null ) && !dependencySet.getOutputFileNameMapping().equals( "${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}" ) ) |
242 | |
{ |
243 | 0 | serializer.startTag( NAMESPACE, "outputFileNameMapping" ).text( dependencySet.getOutputFileNameMapping() ).endTag( NAMESPACE, "outputFileNameMapping" ); |
244 | |
} |
245 | 0 | if ( dependencySet.isUnpack() != false ) |
246 | |
{ |
247 | 0 | serializer.startTag( NAMESPACE, "unpack" ).text( String.valueOf( dependencySet.isUnpack() ) ).endTag( NAMESPACE, "unpack" ); |
248 | |
} |
249 | 0 | if ( dependencySet.getUnpackOptions() != null ) |
250 | |
{ |
251 | 0 | writeUnpackOptions( (UnpackOptions) dependencySet.getUnpackOptions(), "unpackOptions", serializer ); |
252 | |
} |
253 | 0 | if ( ( dependencySet.getScope() != null ) && !dependencySet.getScope().equals( "runtime" ) ) |
254 | |
{ |
255 | 0 | serializer.startTag( NAMESPACE, "scope" ).text( dependencySet.getScope() ).endTag( NAMESPACE, "scope" ); |
256 | |
} |
257 | 0 | if ( dependencySet.isUseProjectArtifact() != true ) |
258 | |
{ |
259 | 0 | serializer.startTag( NAMESPACE, "useProjectArtifact" ).text( String.valueOf( dependencySet.isUseProjectArtifact() ) ).endTag( NAMESPACE, "useProjectArtifact" ); |
260 | |
} |
261 | 0 | if ( dependencySet.isUseProjectAttachments() != false ) |
262 | |
{ |
263 | 0 | serializer.startTag( NAMESPACE, "useProjectAttachments" ).text( String.valueOf( dependencySet.isUseProjectAttachments() ) ).endTag( NAMESPACE, "useProjectAttachments" ); |
264 | |
} |
265 | 0 | if ( dependencySet.isUseTransitiveDependencies() != true ) |
266 | |
{ |
267 | 0 | serializer.startTag( NAMESPACE, "useTransitiveDependencies" ).text( String.valueOf( dependencySet.isUseTransitiveDependencies() ) ).endTag( NAMESPACE, "useTransitiveDependencies" ); |
268 | |
} |
269 | 0 | if ( dependencySet.isUseTransitiveFiltering() != false ) |
270 | |
{ |
271 | 0 | serializer.startTag( NAMESPACE, "useTransitiveFiltering" ).text( String.valueOf( dependencySet.isUseTransitiveFiltering() ) ).endTag( NAMESPACE, "useTransitiveFiltering" ); |
272 | |
} |
273 | 0 | serializer.endTag( NAMESPACE, tagName ); |
274 | 0 | } |
275 | |
|
276 | |
|
277 | |
|
278 | |
|
279 | |
|
280 | |
|
281 | |
|
282 | |
|
283 | |
|
284 | |
private void writeFileItem( FileItem fileItem, String tagName, XmlSerializer serializer ) |
285 | |
throws java.io.IOException |
286 | |
{ |
287 | 0 | serializer.startTag( NAMESPACE, tagName ); |
288 | 0 | if ( fileItem.getSource() != null ) |
289 | |
{ |
290 | 0 | serializer.startTag( NAMESPACE, "source" ).text( fileItem.getSource() ).endTag( NAMESPACE, "source" ); |
291 | |
} |
292 | 0 | if ( fileItem.getOutputDirectory() != null ) |
293 | |
{ |
294 | 0 | serializer.startTag( NAMESPACE, "outputDirectory" ).text( fileItem.getOutputDirectory() ).endTag( NAMESPACE, "outputDirectory" ); |
295 | |
} |
296 | 0 | if ( fileItem.getDestName() != null ) |
297 | |
{ |
298 | 0 | serializer.startTag( NAMESPACE, "destName" ).text( fileItem.getDestName() ).endTag( NAMESPACE, "destName" ); |
299 | |
} |
300 | 0 | if ( fileItem.getFileMode() != null ) |
301 | |
{ |
302 | 0 | serializer.startTag( NAMESPACE, "fileMode" ).text( fileItem.getFileMode() ).endTag( NAMESPACE, "fileMode" ); |
303 | |
} |
304 | 0 | if ( fileItem.getLineEnding() != null ) |
305 | |
{ |
306 | 0 | serializer.startTag( NAMESPACE, "lineEnding" ).text( fileItem.getLineEnding() ).endTag( NAMESPACE, "lineEnding" ); |
307 | |
} |
308 | 0 | if ( fileItem.isFiltered() != false ) |
309 | |
{ |
310 | 0 | serializer.startTag( NAMESPACE, "filtered" ).text( String.valueOf( fileItem.isFiltered() ) ).endTag( NAMESPACE, "filtered" ); |
311 | |
} |
312 | 0 | serializer.endTag( NAMESPACE, tagName ); |
313 | 0 | } |
314 | |
|
315 | |
|
316 | |
|
317 | |
|
318 | |
|
319 | |
|
320 | |
|
321 | |
|
322 | |
|
323 | |
private void writeFileSet( FileSet fileSet, String tagName, XmlSerializer serializer ) |
324 | |
throws java.io.IOException |
325 | |
{ |
326 | 3 | serializer.startTag( NAMESPACE, tagName ); |
327 | 3 | if ( fileSet.isUseDefaultExcludes() != true ) |
328 | |
{ |
329 | 0 | serializer.startTag( NAMESPACE, "useDefaultExcludes" ).text( String.valueOf( fileSet.isUseDefaultExcludes() ) ).endTag( NAMESPACE, "useDefaultExcludes" ); |
330 | |
} |
331 | 3 | if ( fileSet.getOutputDirectory() != null ) |
332 | |
{ |
333 | 0 | serializer.startTag( NAMESPACE, "outputDirectory" ).text( fileSet.getOutputDirectory() ).endTag( NAMESPACE, "outputDirectory" ); |
334 | |
} |
335 | 3 | if ( ( fileSet.getIncludes() != null ) && ( fileSet.getIncludes().size() > 0 ) ) |
336 | |
{ |
337 | 0 | serializer.startTag( NAMESPACE, "includes" ); |
338 | 0 | for ( Iterator iter = fileSet.getIncludes().iterator(); iter.hasNext(); ) |
339 | |
{ |
340 | 0 | String include = (String) iter.next(); |
341 | 0 | serializer.startTag( NAMESPACE, "include" ).text( include ).endTag( NAMESPACE, "include" ); |
342 | 0 | } |
343 | 0 | serializer.endTag( NAMESPACE, "includes" ); |
344 | |
} |
345 | 3 | if ( ( fileSet.getExcludes() != null ) && ( fileSet.getExcludes().size() > 0 ) ) |
346 | |
{ |
347 | 0 | serializer.startTag( NAMESPACE, "excludes" ); |
348 | 0 | for ( Iterator iter = fileSet.getExcludes().iterator(); iter.hasNext(); ) |
349 | |
{ |
350 | 0 | String exclude = (String) iter.next(); |
351 | 0 | serializer.startTag( NAMESPACE, "exclude" ).text( exclude ).endTag( NAMESPACE, "exclude" ); |
352 | 0 | } |
353 | 0 | serializer.endTag( NAMESPACE, "excludes" ); |
354 | |
} |
355 | 3 | if ( fileSet.getFileMode() != null ) |
356 | |
{ |
357 | 0 | serializer.startTag( NAMESPACE, "fileMode" ).text( fileSet.getFileMode() ).endTag( NAMESPACE, "fileMode" ); |
358 | |
} |
359 | 3 | if ( fileSet.getDirectoryMode() != null ) |
360 | |
{ |
361 | 0 | serializer.startTag( NAMESPACE, "directoryMode" ).text( fileSet.getDirectoryMode() ).endTag( NAMESPACE, "directoryMode" ); |
362 | |
} |
363 | 3 | if ( fileSet.getDirectory() != null ) |
364 | |
{ |
365 | 3 | serializer.startTag( NAMESPACE, "directory" ).text( fileSet.getDirectory() ).endTag( NAMESPACE, "directory" ); |
366 | |
} |
367 | 3 | if ( fileSet.getLineEnding() != null ) |
368 | |
{ |
369 | 0 | serializer.startTag( NAMESPACE, "lineEnding" ).text( fileSet.getLineEnding() ).endTag( NAMESPACE, "lineEnding" ); |
370 | |
} |
371 | 3 | if ( fileSet.isFiltered() != false ) |
372 | |
{ |
373 | 0 | serializer.startTag( NAMESPACE, "filtered" ).text( String.valueOf( fileSet.isFiltered() ) ).endTag( NAMESPACE, "filtered" ); |
374 | |
} |
375 | 3 | serializer.endTag( NAMESPACE, tagName ); |
376 | 3 | } |
377 | |
|
378 | |
|
379 | |
|
380 | |
|
381 | |
|
382 | |
|
383 | |
|
384 | |
|
385 | |
|
386 | |
private void writeGroupVersionAlignment( GroupVersionAlignment groupVersionAlignment, String tagName, XmlSerializer serializer ) |
387 | |
throws java.io.IOException |
388 | |
{ |
389 | 0 | serializer.startTag( NAMESPACE, tagName ); |
390 | 0 | if ( groupVersionAlignment.getId() != null ) |
391 | |
{ |
392 | 0 | serializer.startTag( NAMESPACE, "id" ).text( groupVersionAlignment.getId() ).endTag( NAMESPACE, "id" ); |
393 | |
} |
394 | 0 | if ( groupVersionAlignment.getVersion() != null ) |
395 | |
{ |
396 | 0 | serializer.startTag( NAMESPACE, "version" ).text( groupVersionAlignment.getVersion() ).endTag( NAMESPACE, "version" ); |
397 | |
} |
398 | 0 | if ( ( groupVersionAlignment.getExcludes() != null ) && ( groupVersionAlignment.getExcludes().size() > 0 ) ) |
399 | |
{ |
400 | 0 | serializer.startTag( NAMESPACE, "excludes" ); |
401 | 0 | for ( Iterator iter = groupVersionAlignment.getExcludes().iterator(); iter.hasNext(); ) |
402 | |
{ |
403 | 0 | String exclude = (String) iter.next(); |
404 | 0 | serializer.startTag( NAMESPACE, "exclude" ).text( exclude ).endTag( NAMESPACE, "exclude" ); |
405 | 0 | } |
406 | 0 | serializer.endTag( NAMESPACE, "excludes" ); |
407 | |
} |
408 | 0 | serializer.endTag( NAMESPACE, tagName ); |
409 | 0 | } |
410 | |
|
411 | |
|
412 | |
|
413 | |
|
414 | |
|
415 | |
|
416 | |
|
417 | |
|
418 | |
|
419 | |
private void writeModuleBinaries( ModuleBinaries moduleBinaries, String tagName, XmlSerializer serializer ) |
420 | |
throws java.io.IOException |
421 | |
{ |
422 | 0 | serializer.startTag( NAMESPACE, tagName ); |
423 | 0 | if ( moduleBinaries.getOutputDirectory() != null ) |
424 | |
{ |
425 | 0 | serializer.startTag( NAMESPACE, "outputDirectory" ).text( moduleBinaries.getOutputDirectory() ).endTag( NAMESPACE, "outputDirectory" ); |
426 | |
} |
427 | 0 | if ( ( moduleBinaries.getIncludes() != null ) && ( moduleBinaries.getIncludes().size() > 0 ) ) |
428 | |
{ |
429 | 0 | serializer.startTag( NAMESPACE, "includes" ); |
430 | 0 | for ( Iterator iter = moduleBinaries.getIncludes().iterator(); iter.hasNext(); ) |
431 | |
{ |
432 | 0 | String include = (String) iter.next(); |
433 | 0 | serializer.startTag( NAMESPACE, "include" ).text( include ).endTag( NAMESPACE, "include" ); |
434 | 0 | } |
435 | 0 | serializer.endTag( NAMESPACE, "includes" ); |
436 | |
} |
437 | 0 | if ( ( moduleBinaries.getExcludes() != null ) && ( moduleBinaries.getExcludes().size() > 0 ) ) |
438 | |
{ |
439 | 0 | serializer.startTag( NAMESPACE, "excludes" ); |
440 | 0 | for ( Iterator iter = moduleBinaries.getExcludes().iterator(); iter.hasNext(); ) |
441 | |
{ |
442 | 0 | String exclude = (String) iter.next(); |
443 | 0 | serializer.startTag( NAMESPACE, "exclude" ).text( exclude ).endTag( NAMESPACE, "exclude" ); |
444 | 0 | } |
445 | 0 | serializer.endTag( NAMESPACE, "excludes" ); |
446 | |
} |
447 | 0 | if ( moduleBinaries.getFileMode() != null ) |
448 | |
{ |
449 | 0 | serializer.startTag( NAMESPACE, "fileMode" ).text( moduleBinaries.getFileMode() ).endTag( NAMESPACE, "fileMode" ); |
450 | |
} |
451 | 0 | if ( moduleBinaries.getDirectoryMode() != null ) |
452 | |
{ |
453 | 0 | serializer.startTag( NAMESPACE, "directoryMode" ).text( moduleBinaries.getDirectoryMode() ).endTag( NAMESPACE, "directoryMode" ); |
454 | |
} |
455 | 0 | if ( moduleBinaries.getAttachmentClassifier() != null ) |
456 | |
{ |
457 | 0 | serializer.startTag( NAMESPACE, "attachmentClassifier" ).text( moduleBinaries.getAttachmentClassifier() ).endTag( NAMESPACE, "attachmentClassifier" ); |
458 | |
} |
459 | 0 | if ( moduleBinaries.isIncludeDependencies() != true ) |
460 | |
{ |
461 | 0 | serializer.startTag( NAMESPACE, "includeDependencies" ).text( String.valueOf( moduleBinaries.isIncludeDependencies() ) ).endTag( NAMESPACE, "includeDependencies" ); |
462 | |
} |
463 | 0 | if ( ( moduleBinaries.getDependencySets() != null ) && ( moduleBinaries.getDependencySets().size() > 0 ) ) |
464 | |
{ |
465 | 0 | serializer.startTag( NAMESPACE, "dependencySets" ); |
466 | 0 | for ( Iterator iter = moduleBinaries.getDependencySets().iterator(); iter.hasNext(); ) |
467 | |
{ |
468 | 0 | DependencySet o = (DependencySet) iter.next(); |
469 | 0 | writeDependencySet( o, "dependencySet", serializer ); |
470 | 0 | } |
471 | 0 | serializer.endTag( NAMESPACE, "dependencySets" ); |
472 | |
} |
473 | 0 | if ( moduleBinaries.isUnpack() != true ) |
474 | |
{ |
475 | 0 | serializer.startTag( NAMESPACE, "unpack" ).text( String.valueOf( moduleBinaries.isUnpack() ) ).endTag( NAMESPACE, "unpack" ); |
476 | |
} |
477 | 0 | if ( moduleBinaries.getUnpackOptions() != null ) |
478 | |
{ |
479 | 0 | writeUnpackOptions( (UnpackOptions) moduleBinaries.getUnpackOptions(), "unpackOptions", serializer ); |
480 | |
} |
481 | 0 | if ( ( moduleBinaries.getOutputFileNameMapping() != null ) && !moduleBinaries.getOutputFileNameMapping().equals( "${module.artifactId}-${module.version}${dashClassifier?}.${module.extension}" ) ) |
482 | |
{ |
483 | 0 | serializer.startTag( NAMESPACE, "outputFileNameMapping" ).text( moduleBinaries.getOutputFileNameMapping() ).endTag( NAMESPACE, "outputFileNameMapping" ); |
484 | |
} |
485 | 0 | serializer.endTag( NAMESPACE, tagName ); |
486 | 0 | } |
487 | |
|
488 | |
|
489 | |
|
490 | |
|
491 | |
|
492 | |
|
493 | |
|
494 | |
|
495 | |
|
496 | |
private void writeModuleSet( ModuleSet moduleSet, String tagName, XmlSerializer serializer ) |
497 | |
throws java.io.IOException |
498 | |
{ |
499 | 0 | serializer.startTag( NAMESPACE, tagName ); |
500 | 0 | if ( moduleSet.isUseAllReactorProjects() != false ) |
501 | |
{ |
502 | 0 | serializer.startTag( NAMESPACE, "useAllReactorProjects" ).text( String.valueOf( moduleSet.isUseAllReactorProjects() ) ).endTag( NAMESPACE, "useAllReactorProjects" ); |
503 | |
} |
504 | 0 | if ( moduleSet.isIncludeSubModules() != true ) |
505 | |
{ |
506 | 0 | serializer.startTag( NAMESPACE, "includeSubModules" ).text( String.valueOf( moduleSet.isIncludeSubModules() ) ).endTag( NAMESPACE, "includeSubModules" ); |
507 | |
} |
508 | 0 | if ( ( moduleSet.getIncludes() != null ) && ( moduleSet.getIncludes().size() > 0 ) ) |
509 | |
{ |
510 | 0 | serializer.startTag( NAMESPACE, "includes" ); |
511 | 0 | for ( Iterator iter = moduleSet.getIncludes().iterator(); iter.hasNext(); ) |
512 | |
{ |
513 | 0 | String include = (String) iter.next(); |
514 | 0 | serializer.startTag( NAMESPACE, "include" ).text( include ).endTag( NAMESPACE, "include" ); |
515 | 0 | } |
516 | 0 | serializer.endTag( NAMESPACE, "includes" ); |
517 | |
} |
518 | 0 | if ( ( moduleSet.getExcludes() != null ) && ( moduleSet.getExcludes().size() > 0 ) ) |
519 | |
{ |
520 | 0 | serializer.startTag( NAMESPACE, "excludes" ); |
521 | 0 | for ( Iterator iter = moduleSet.getExcludes().iterator(); iter.hasNext(); ) |
522 | |
{ |
523 | 0 | String exclude = (String) iter.next(); |
524 | 0 | serializer.startTag( NAMESPACE, "exclude" ).text( exclude ).endTag( NAMESPACE, "exclude" ); |
525 | 0 | } |
526 | 0 | serializer.endTag( NAMESPACE, "excludes" ); |
527 | |
} |
528 | 0 | if ( moduleSet.getSources() != null ) |
529 | |
{ |
530 | 0 | writeModuleSources( (ModuleSources) moduleSet.getSources(), "sources", serializer ); |
531 | |
} |
532 | 0 | if ( moduleSet.getBinaries() != null ) |
533 | |
{ |
534 | 0 | writeModuleBinaries( (ModuleBinaries) moduleSet.getBinaries(), "binaries", serializer ); |
535 | |
} |
536 | 0 | serializer.endTag( NAMESPACE, tagName ); |
537 | 0 | } |
538 | |
|
539 | |
|
540 | |
|
541 | |
|
542 | |
|
543 | |
|
544 | |
|
545 | |
|
546 | |
|
547 | |
private void writeModuleSources( ModuleSources moduleSources, String tagName, XmlSerializer serializer ) |
548 | |
throws java.io.IOException |
549 | |
{ |
550 | 0 | serializer.startTag( NAMESPACE, tagName ); |
551 | 0 | if ( moduleSources.isUseDefaultExcludes() != true ) |
552 | |
{ |
553 | 0 | serializer.startTag( NAMESPACE, "useDefaultExcludes" ).text( String.valueOf( moduleSources.isUseDefaultExcludes() ) ).endTag( NAMESPACE, "useDefaultExcludes" ); |
554 | |
} |
555 | 0 | if ( moduleSources.getOutputDirectory() != null ) |
556 | |
{ |
557 | 0 | serializer.startTag( NAMESPACE, "outputDirectory" ).text( moduleSources.getOutputDirectory() ).endTag( NAMESPACE, "outputDirectory" ); |
558 | |
} |
559 | 0 | if ( ( moduleSources.getIncludes() != null ) && ( moduleSources.getIncludes().size() > 0 ) ) |
560 | |
{ |
561 | 0 | serializer.startTag( NAMESPACE, "includes" ); |
562 | 0 | for ( Iterator iter = moduleSources.getIncludes().iterator(); iter.hasNext(); ) |
563 | |
{ |
564 | 0 | String include = (String) iter.next(); |
565 | 0 | serializer.startTag( NAMESPACE, "include" ).text( include ).endTag( NAMESPACE, "include" ); |
566 | 0 | } |
567 | 0 | serializer.endTag( NAMESPACE, "includes" ); |
568 | |
} |
569 | 0 | if ( ( moduleSources.getExcludes() != null ) && ( moduleSources.getExcludes().size() > 0 ) ) |
570 | |
{ |
571 | 0 | serializer.startTag( NAMESPACE, "excludes" ); |
572 | 0 | for ( Iterator iter = moduleSources.getExcludes().iterator(); iter.hasNext(); ) |
573 | |
{ |
574 | 0 | String exclude = (String) iter.next(); |
575 | 0 | serializer.startTag( NAMESPACE, "exclude" ).text( exclude ).endTag( NAMESPACE, "exclude" ); |
576 | 0 | } |
577 | 0 | serializer.endTag( NAMESPACE, "excludes" ); |
578 | |
} |
579 | 0 | if ( moduleSources.getFileMode() != null ) |
580 | |
{ |
581 | 0 | serializer.startTag( NAMESPACE, "fileMode" ).text( moduleSources.getFileMode() ).endTag( NAMESPACE, "fileMode" ); |
582 | |
} |
583 | 0 | if ( moduleSources.getDirectoryMode() != null ) |
584 | |
{ |
585 | 0 | serializer.startTag( NAMESPACE, "directoryMode" ).text( moduleSources.getDirectoryMode() ).endTag( NAMESPACE, "directoryMode" ); |
586 | |
} |
587 | 0 | if ( ( moduleSources.getFileSets() != null ) && ( moduleSources.getFileSets().size() > 0 ) ) |
588 | |
{ |
589 | 0 | serializer.startTag( NAMESPACE, "fileSets" ); |
590 | 0 | for ( Iterator iter = moduleSources.getFileSets().iterator(); iter.hasNext(); ) |
591 | |
{ |
592 | 0 | FileSet o = (FileSet) iter.next(); |
593 | 0 | writeFileSet( o, "fileSet", serializer ); |
594 | 0 | } |
595 | 0 | serializer.endTag( NAMESPACE, "fileSets" ); |
596 | |
} |
597 | 0 | if ( moduleSources.isIncludeModuleDirectory() != true ) |
598 | |
{ |
599 | 0 | serializer.startTag( NAMESPACE, "includeModuleDirectory" ).text( String.valueOf( moduleSources.isIncludeModuleDirectory() ) ).endTag( NAMESPACE, "includeModuleDirectory" ); |
600 | |
} |
601 | 0 | if ( moduleSources.isExcludeSubModuleDirectories() != true ) |
602 | |
{ |
603 | 0 | serializer.startTag( NAMESPACE, "excludeSubModuleDirectories" ).text( String.valueOf( moduleSources.isExcludeSubModuleDirectories() ) ).endTag( NAMESPACE, "excludeSubModuleDirectories" ); |
604 | |
} |
605 | 0 | if ( ( moduleSources.getOutputDirectoryMapping() != null ) && !moduleSources.getOutputDirectoryMapping().equals( "${module.artifactId}" ) ) |
606 | |
{ |
607 | 0 | serializer.startTag( NAMESPACE, "outputDirectoryMapping" ).text( moduleSources.getOutputDirectoryMapping() ).endTag( NAMESPACE, "outputDirectoryMapping" ); |
608 | |
} |
609 | 0 | serializer.endTag( NAMESPACE, tagName ); |
610 | 0 | } |
611 | |
|
612 | |
|
613 | |
|
614 | |
|
615 | |
|
616 | |
|
617 | |
|
618 | |
|
619 | |
|
620 | |
private void writeRepository( Repository repository, String tagName, XmlSerializer serializer ) |
621 | |
throws java.io.IOException |
622 | |
{ |
623 | 0 | serializer.startTag( NAMESPACE, tagName ); |
624 | 0 | if ( repository.getOutputDirectory() != null ) |
625 | |
{ |
626 | 0 | serializer.startTag( NAMESPACE, "outputDirectory" ).text( repository.getOutputDirectory() ).endTag( NAMESPACE, "outputDirectory" ); |
627 | |
} |
628 | 0 | if ( ( repository.getIncludes() != null ) && ( repository.getIncludes().size() > 0 ) ) |
629 | |
{ |
630 | 0 | serializer.startTag( NAMESPACE, "includes" ); |
631 | 0 | for ( Iterator iter = repository.getIncludes().iterator(); iter.hasNext(); ) |
632 | |
{ |
633 | 0 | String include = (String) iter.next(); |
634 | 0 | serializer.startTag( NAMESPACE, "include" ).text( include ).endTag( NAMESPACE, "include" ); |
635 | 0 | } |
636 | 0 | serializer.endTag( NAMESPACE, "includes" ); |
637 | |
} |
638 | 0 | if ( ( repository.getExcludes() != null ) && ( repository.getExcludes().size() > 0 ) ) |
639 | |
{ |
640 | 0 | serializer.startTag( NAMESPACE, "excludes" ); |
641 | 0 | for ( Iterator iter = repository.getExcludes().iterator(); iter.hasNext(); ) |
642 | |
{ |
643 | 0 | String exclude = (String) iter.next(); |
644 | 0 | serializer.startTag( NAMESPACE, "exclude" ).text( exclude ).endTag( NAMESPACE, "exclude" ); |
645 | 0 | } |
646 | 0 | serializer.endTag( NAMESPACE, "excludes" ); |
647 | |
} |
648 | 0 | if ( repository.getFileMode() != null ) |
649 | |
{ |
650 | 0 | serializer.startTag( NAMESPACE, "fileMode" ).text( repository.getFileMode() ).endTag( NAMESPACE, "fileMode" ); |
651 | |
} |
652 | 0 | if ( repository.getDirectoryMode() != null ) |
653 | |
{ |
654 | 0 | serializer.startTag( NAMESPACE, "directoryMode" ).text( repository.getDirectoryMode() ).endTag( NAMESPACE, "directoryMode" ); |
655 | |
} |
656 | 0 | if ( repository.isIncludeMetadata() != false ) |
657 | |
{ |
658 | 0 | serializer.startTag( NAMESPACE, "includeMetadata" ).text( String.valueOf( repository.isIncludeMetadata() ) ).endTag( NAMESPACE, "includeMetadata" ); |
659 | |
} |
660 | 0 | if ( ( repository.getGroupVersionAlignments() != null ) && ( repository.getGroupVersionAlignments().size() > 0 ) ) |
661 | |
{ |
662 | 0 | serializer.startTag( NAMESPACE, "groupVersionAlignments" ); |
663 | 0 | for ( Iterator iter = repository.getGroupVersionAlignments().iterator(); iter.hasNext(); ) |
664 | |
{ |
665 | 0 | GroupVersionAlignment o = (GroupVersionAlignment) iter.next(); |
666 | 0 | writeGroupVersionAlignment( o, "groupVersionAlignment", serializer ); |
667 | 0 | } |
668 | 0 | serializer.endTag( NAMESPACE, "groupVersionAlignments" ); |
669 | |
} |
670 | 0 | if ( ( repository.getScope() != null ) && !repository.getScope().equals( "runtime" ) ) |
671 | |
{ |
672 | 0 | serializer.startTag( NAMESPACE, "scope" ).text( repository.getScope() ).endTag( NAMESPACE, "scope" ); |
673 | |
} |
674 | 0 | serializer.endTag( NAMESPACE, tagName ); |
675 | 0 | } |
676 | |
|
677 | |
|
678 | |
|
679 | |
|
680 | |
|
681 | |
|
682 | |
|
683 | |
|
684 | |
|
685 | |
private void writeUnpackOptions( UnpackOptions unpackOptions, String tagName, XmlSerializer serializer ) |
686 | |
throws java.io.IOException |
687 | |
{ |
688 | 0 | serializer.startTag( NAMESPACE, tagName ); |
689 | 0 | if ( ( unpackOptions.getIncludes() != null ) && ( unpackOptions.getIncludes().size() > 0 ) ) |
690 | |
{ |
691 | 0 | serializer.startTag( NAMESPACE, "includes" ); |
692 | 0 | for ( Iterator iter = unpackOptions.getIncludes().iterator(); iter.hasNext(); ) |
693 | |
{ |
694 | 0 | String include = (String) iter.next(); |
695 | 0 | serializer.startTag( NAMESPACE, "include" ).text( include ).endTag( NAMESPACE, "include" ); |
696 | 0 | } |
697 | 0 | serializer.endTag( NAMESPACE, "includes" ); |
698 | |
} |
699 | 0 | if ( ( unpackOptions.getExcludes() != null ) && ( unpackOptions.getExcludes().size() > 0 ) ) |
700 | |
{ |
701 | 0 | serializer.startTag( NAMESPACE, "excludes" ); |
702 | 0 | for ( Iterator iter = unpackOptions.getExcludes().iterator(); iter.hasNext(); ) |
703 | |
{ |
704 | 0 | String exclude = (String) iter.next(); |
705 | 0 | serializer.startTag( NAMESPACE, "exclude" ).text( exclude ).endTag( NAMESPACE, "exclude" ); |
706 | 0 | } |
707 | 0 | serializer.endTag( NAMESPACE, "excludes" ); |
708 | |
} |
709 | 0 | if ( unpackOptions.isFiltered() != false ) |
710 | |
{ |
711 | 0 | serializer.startTag( NAMESPACE, "filtered" ).text( String.valueOf( unpackOptions.isFiltered() ) ).endTag( NAMESPACE, "filtered" ); |
712 | |
} |
713 | 0 | if ( unpackOptions.getLineEnding() != null ) |
714 | |
{ |
715 | 0 | serializer.startTag( NAMESPACE, "lineEnding" ).text( unpackOptions.getLineEnding() ).endTag( NAMESPACE, "lineEnding" ); |
716 | |
} |
717 | 0 | if ( unpackOptions.isUseDefaultExcludes() != true ) |
718 | |
{ |
719 | 0 | serializer.startTag( NAMESPACE, "useDefaultExcludes" ).text( String.valueOf( unpackOptions.isUseDefaultExcludes() ) ).endTag( NAMESPACE, "useDefaultExcludes" ); |
720 | |
} |
721 | 0 | serializer.endTag( NAMESPACE, tagName ); |
722 | 0 | } |
723 | |
|
724 | |
} |