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