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