1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.apache.maven.buildcache.xml.config.io.xpp3;
25
26
27
28
29
30 import java.io.OutputStream;
31 import java.io.Writer;
32 import java.util.Iterator;
33 import org.apache.maven.buildcache.xml.config.AttachedOutputs;
34 import org.apache.maven.buildcache.xml.config.CacheConfig;
35 import org.apache.maven.buildcache.xml.config.Configuration;
36 import org.apache.maven.buildcache.xml.config.CoordinatesBase;
37 import org.apache.maven.buildcache.xml.config.DirName;
38 import org.apache.maven.buildcache.xml.config.DirScanConfig;
39 import org.apache.maven.buildcache.xml.config.Discovery;
40 import org.apache.maven.buildcache.xml.config.EffectivePom;
41 import org.apache.maven.buildcache.xml.config.Exclude;
42 import org.apache.maven.buildcache.xml.config.Executables;
43 import org.apache.maven.buildcache.xml.config.ExecutionConfigurationScan;
44 import org.apache.maven.buildcache.xml.config.ExecutionControl;
45 import org.apache.maven.buildcache.xml.config.ExecutionIdsList;
46 import org.apache.maven.buildcache.xml.config.GoalId;
47 import org.apache.maven.buildcache.xml.config.GoalReconciliation;
48 import org.apache.maven.buildcache.xml.config.GoalsList;
49 import org.apache.maven.buildcache.xml.config.Include;
50 import org.apache.maven.buildcache.xml.config.Input;
51 import org.apache.maven.buildcache.xml.config.Local;
52 import org.apache.maven.buildcache.xml.config.MultiModule;
53 import org.apache.maven.buildcache.xml.config.Output;
54 import org.apache.maven.buildcache.xml.config.OutputExclude;
55 import org.apache.maven.buildcache.xml.config.PathSet;
56 import org.apache.maven.buildcache.xml.config.PluginConfigurationScan;
57 import org.apache.maven.buildcache.xml.config.PluginSet;
58 import org.apache.maven.buildcache.xml.config.ProjectVersioning;
59 import org.apache.maven.buildcache.xml.config.PropertyName;
60 import org.apache.maven.buildcache.xml.config.Reconcile;
61 import org.apache.maven.buildcache.xml.config.Remote;
62 import org.apache.maven.buildcache.xml.config.TagExclude;
63 import org.apache.maven.buildcache.xml.config.TagScanConfig;
64 import org.apache.maven.buildcache.xml.config.TrackedProperty;
65 import org.codehaus.plexus.util.xml.pull.MXSerializer;
66 import org.codehaus.plexus.util.xml.pull.XmlSerializer;
67
68
69
70
71
72
73 @SuppressWarnings( "all" )
74 public class BuildCacheConfigXpp3Writer
75 {
76
77
78
79
80
81
82
83
84 private static final String NAMESPACE = null;
85
86
87
88
89 private String fileComment = null;
90
91
92
93
94
95
96
97
98
99
100
101 public void setFileComment( String fileComment )
102 {
103 this.fileComment = fileComment;
104 }
105
106
107
108
109
110
111
112
113 public void write( Writer writer, CacheConfig cacheConfig )
114 throws java.io.IOException
115 {
116 XmlSerializer serializer = new MXSerializer();
117 serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " );
118 serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
119 serializer.setOutput( writer );
120 serializer.startDocument( cacheConfig.getModelEncoding(), null );
121 writeCacheConfig( cacheConfig, "cache", serializer );
122 serializer.endDocument();
123 }
124
125
126
127
128
129
130
131
132 public void write( OutputStream stream, CacheConfig cacheConfig )
133 throws java.io.IOException
134 {
135 XmlSerializer serializer = new MXSerializer();
136 serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " );
137 serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
138 serializer.setOutput( stream, cacheConfig.getModelEncoding() );
139 serializer.startDocument( cacheConfig.getModelEncoding(), null );
140 writeCacheConfig( cacheConfig, "cache", serializer );
141 serializer.endDocument();
142 }
143
144
145
146
147
148
149
150
151
152 private void writeAttachedOutputs( AttachedOutputs attachedOutputs, String tagName, XmlSerializer serializer )
153 throws java.io.IOException
154 {
155 serializer.startTag( NAMESPACE, tagName );
156 if ( attachedOutputs.isPreservePermissions() != true )
157 {
158 serializer.startTag( NAMESPACE, "preservePermissions" ).text( String.valueOf( attachedOutputs.isPreservePermissions() ) ).endTag( NAMESPACE, "preservePermissions" );
159 }
160 if ( ( attachedOutputs.getDirNames() != null ) && ( attachedOutputs.getDirNames().size() > 0 ) )
161 {
162 serializer.startTag( NAMESPACE, "dirNames" );
163 for ( Iterator iter = attachedOutputs.getDirNames().iterator(); iter.hasNext(); )
164 {
165 DirName o = (DirName) iter.next();
166 writeDirName( o, "dirName", serializer );
167 }
168 serializer.endTag( NAMESPACE, "dirNames" );
169 }
170 serializer.endTag( NAMESPACE, tagName );
171 }
172
173
174
175
176
177
178
179
180
181 private void writeCacheConfig( CacheConfig cacheConfig, String tagName, XmlSerializer serializer )
182 throws java.io.IOException
183 {
184 if ( this.fileComment != null )
185 {
186 serializer.comment(this.fileComment);
187 }
188 serializer.setPrefix( "", "http://maven.apache.org/BUILD-CACHE-CONFIG/1.2.0" );
189 serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
190 serializer.startTag( NAMESPACE, tagName );
191 serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/BUILD-CACHE-CONFIG/1.2.0 https://maven.apache.org/xsd/build-cache-config-1.2.0.xsd" );
192 if ( cacheConfig.getConfiguration() != null )
193 {
194 writeConfiguration( (Configuration) cacheConfig.getConfiguration(), "configuration", serializer );
195 }
196 if ( cacheConfig.getInput() != null )
197 {
198 writeInput( (Input) cacheConfig.getInput(), "input", serializer );
199 }
200 if ( cacheConfig.getOutput() != null )
201 {
202 writeOutput( (Output) cacheConfig.getOutput(), "output", serializer );
203 }
204 if ( cacheConfig.getExecutionControl() != null )
205 {
206 writeExecutionControl( (ExecutionControl) cacheConfig.getExecutionControl(), "executionControl", serializer );
207 }
208 serializer.endTag( NAMESPACE, tagName );
209 }
210
211
212
213
214
215
216
217
218
219 private void writeConfiguration( Configuration configuration, String tagName, XmlSerializer serializer )
220 throws java.io.IOException
221 {
222 serializer.startTag( NAMESPACE, tagName );
223 if ( configuration.isEnabled() != true )
224 {
225 serializer.startTag( NAMESPACE, "enabled" ).text( String.valueOf( configuration.isEnabled() ) ).endTag( NAMESPACE, "enabled" );
226 }
227 if ( ( configuration.getHashAlgorithm() != null ) && !configuration.getHashAlgorithm().equals( "XX" ) )
228 {
229 serializer.startTag( NAMESPACE, "hashAlgorithm" ).text( configuration.getHashAlgorithm() ).endTag( NAMESPACE, "hashAlgorithm" );
230 }
231 if ( configuration.isValidateXml() != false )
232 {
233 serializer.startTag( NAMESPACE, "validateXml" ).text( String.valueOf( configuration.isValidateXml() ) ).endTag( NAMESPACE, "validateXml" );
234 }
235 if ( configuration.isMandatoryClean() != false )
236 {
237 serializer.startTag( NAMESPACE, "mandatoryClean" ).text( String.valueOf( configuration.isMandatoryClean() ) ).endTag( NAMESPACE, "mandatoryClean" );
238 }
239 if ( configuration.getMultiModule() != null )
240 {
241 writeMultiModule( (MultiModule) configuration.getMultiModule(), "multiModule", serializer );
242 }
243 if ( configuration.getProjectVersioning() != null )
244 {
245 writeProjectVersioning( (ProjectVersioning) configuration.getProjectVersioning(), "projectVersioning", serializer );
246 }
247 if ( configuration.getRemote() != null )
248 {
249 writeRemote( (Remote) configuration.getRemote(), "remote", serializer );
250 }
251 if ( configuration.getAttachedOutputs() != null )
252 {
253 writeAttachedOutputs( (AttachedOutputs) configuration.getAttachedOutputs(), "attachedOutputs", serializer );
254 }
255 if ( configuration.getLocal() != null )
256 {
257 writeLocal( (Local) configuration.getLocal(), "local", serializer );
258 }
259 if ( ( configuration.getDebugs() != null ) && ( configuration.getDebugs().size() > 0 ) )
260 {
261 serializer.startTag( NAMESPACE, "debugs" );
262 for ( Iterator iter = configuration.getDebugs().iterator(); iter.hasNext(); )
263 {
264 String debug = (String) iter.next();
265 serializer.startTag( NAMESPACE, "debug" ).text( debug ).endTag( NAMESPACE, "debug" );
266 }
267 serializer.endTag( NAMESPACE, "debugs" );
268 }
269 serializer.endTag( NAMESPACE, tagName );
270 }
271
272
273
274
275
276
277
278
279
280 private void writeCoordinatesBase( CoordinatesBase coordinatesBase, String tagName, XmlSerializer serializer )
281 throws java.io.IOException
282 {
283 serializer.startTag( NAMESPACE, tagName );
284 if ( coordinatesBase.getGroupId() != null )
285 {
286 serializer.attribute( NAMESPACE, "groupId", coordinatesBase.getGroupId() );
287 }
288 if ( coordinatesBase.getArtifactId() != null )
289 {
290 serializer.attribute( NAMESPACE, "artifactId", coordinatesBase.getArtifactId() );
291 }
292 serializer.endTag( NAMESPACE, tagName );
293 }
294
295
296
297
298
299
300
301
302
303 private void writeDirName( DirName dirName, String tagName, XmlSerializer serializer )
304 throws java.io.IOException
305 {
306 serializer.startTag( NAMESPACE, tagName );
307 if ( ( dirName.getGlob() != null ) && !dirName.getGlob().equals( "*" ) )
308 {
309 serializer.attribute( NAMESPACE, "glob", dirName.getGlob() );
310 }
311 serializer.text( dirName.getValue() );
312 serializer.endTag( NAMESPACE, tagName );
313 }
314
315
316
317
318
319
320
321
322
323 private void writeDirScanConfig( DirScanConfig dirScanConfig, String tagName, XmlSerializer serializer )
324 throws java.io.IOException
325 {
326 serializer.startTag( NAMESPACE, tagName );
327 if ( dirScanConfig.isIgnoreParent() != false )
328 {
329 serializer.attribute( NAMESPACE, "ignoreParent", String.valueOf( dirScanConfig.isIgnoreParent() ) );
330 }
331 if ( dirScanConfig.getMode() != null )
332 {
333 serializer.attribute( NAMESPACE, "mode", dirScanConfig.getMode() );
334 }
335 if ( ( dirScanConfig.getIncludes() != null ) && ( dirScanConfig.getIncludes().size() > 0 ) )
336 {
337 serializer.startTag( NAMESPACE, "includes" );
338 for ( Iterator iter = dirScanConfig.getIncludes().iterator(); iter.hasNext(); )
339 {
340 TagScanConfig o = (TagScanConfig) iter.next();
341 writeTagScanConfig( o, "include", serializer );
342 }
343 serializer.endTag( NAMESPACE, "includes" );
344 }
345 if ( ( dirScanConfig.getExcludes() != null ) && ( dirScanConfig.getExcludes().size() > 0 ) )
346 {
347 serializer.startTag( NAMESPACE, "excludes" );
348 for ( Iterator iter = dirScanConfig.getExcludes().iterator(); iter.hasNext(); )
349 {
350 TagExclude o = (TagExclude) iter.next();
351 writeTagExclude( o, "exclude", serializer );
352 }
353 serializer.endTag( NAMESPACE, "excludes" );
354 }
355 if ( ( dirScanConfig.getTagScanConfigs() != null ) && ( dirScanConfig.getTagScanConfigs().size() > 0 ) )
356 {
357 serializer.startTag( NAMESPACE, "tagScanConfigs" );
358 for ( Iterator iter = dirScanConfig.getTagScanConfigs().iterator(); iter.hasNext(); )
359 {
360 TagScanConfig o = (TagScanConfig) iter.next();
361 writeTagScanConfig( o, "tagScanConfig", serializer );
362 }
363 serializer.endTag( NAMESPACE, "tagScanConfigs" );
364 }
365 serializer.endTag( NAMESPACE, tagName );
366 }
367
368
369
370
371
372
373
374
375
376 private void writeDiscovery( Discovery discovery, String tagName, XmlSerializer serializer )
377 throws java.io.IOException
378 {
379 serializer.startTag( NAMESPACE, tagName );
380 if ( ( discovery.getScanProfiles() != null ) && ( discovery.getScanProfiles().size() > 0 ) )
381 {
382 serializer.startTag( NAMESPACE, "scanProfiles" );
383 for ( Iterator iter = discovery.getScanProfiles().iterator(); iter.hasNext(); )
384 {
385 String scanProfile = (String) iter.next();
386 serializer.startTag( NAMESPACE, "scanProfile" ).text( scanProfile ).endTag( NAMESPACE, "scanProfile" );
387 }
388 serializer.endTag( NAMESPACE, "scanProfiles" );
389 }
390 serializer.endTag( NAMESPACE, tagName );
391 }
392
393
394
395
396
397
398
399
400
401 private void writeEffectivePom( EffectivePom effectivePom, String tagName, XmlSerializer serializer )
402 throws java.io.IOException
403 {
404 serializer.startTag( NAMESPACE, tagName );
405 if ( ( effectivePom.getExcludeProperties() != null ) && ( effectivePom.getExcludeProperties().size() > 0 ) )
406 {
407 serializer.startTag( NAMESPACE, "excludeProperties" );
408 for ( Iterator iter = effectivePom.getExcludeProperties().iterator(); iter.hasNext(); )
409 {
410 String excludeProperty = (String) iter.next();
411 serializer.startTag( NAMESPACE, "excludeProperty" ).text( excludeProperty ).endTag( NAMESPACE, "excludeProperty" );
412 }
413 serializer.endTag( NAMESPACE, "excludeProperties" );
414 }
415 serializer.endTag( NAMESPACE, tagName );
416 }
417
418
419
420
421
422
423
424
425
426 private void writeExclude( Exclude exclude, String tagName, XmlSerializer serializer )
427 throws java.io.IOException
428 {
429 serializer.startTag( NAMESPACE, tagName );
430 if ( ( exclude.getGlob() != null ) && !exclude.getGlob().equals( "**" ) )
431 {
432 serializer.attribute( NAMESPACE, "glob", exclude.getGlob() );
433 }
434 if ( ( exclude.getEntryType() != null ) && !exclude.getEntryType().equals( "ALL" ) )
435 {
436 serializer.attribute( NAMESPACE, "entryType", exclude.getEntryType() );
437 }
438 if ( ( exclude.getMatcherType() != null ) && !exclude.getMatcherType().equals( "FILENAME" ) )
439 {
440 serializer.attribute( NAMESPACE, "matcherType", exclude.getMatcherType() );
441 }
442 serializer.text( exclude.getValue() );
443 serializer.endTag( NAMESPACE, tagName );
444 }
445
446
447
448
449
450
451
452
453
454 private void writeExecutables( Executables executables, String tagName, XmlSerializer serializer )
455 throws java.io.IOException
456 {
457 serializer.startTag( NAMESPACE, tagName );
458 if ( ( executables.getPlugins() != null ) && ( executables.getPlugins().size() > 0 ) )
459 {
460 serializer.startTag( NAMESPACE, "plugins" );
461 for ( Iterator iter = executables.getPlugins().iterator(); iter.hasNext(); )
462 {
463 PluginSet o = (PluginSet) iter.next();
464 writePluginSet( o, "plugin", serializer );
465 }
466 serializer.endTag( NAMESPACE, "plugins" );
467 }
468 if ( ( executables.getExecutions() != null ) && ( executables.getExecutions().size() > 0 ) )
469 {
470 serializer.startTag( NAMESPACE, "executions" );
471 for ( Iterator iter = executables.getExecutions().iterator(); iter.hasNext(); )
472 {
473 ExecutionIdsList o = (ExecutionIdsList) iter.next();
474 writeExecutionIdsList( o, "execution", serializer );
475 }
476 serializer.endTag( NAMESPACE, "executions" );
477 }
478 if ( ( executables.getGoalsLists() != null ) && ( executables.getGoalsLists().size() > 0 ) )
479 {
480 serializer.startTag( NAMESPACE, "goalsLists" );
481 for ( Iterator iter = executables.getGoalsLists().iterator(); iter.hasNext(); )
482 {
483 GoalsList o = (GoalsList) iter.next();
484 writeGoalsList( o, "goalsList", serializer );
485 }
486 serializer.endTag( NAMESPACE, "goalsLists" );
487 }
488 serializer.endTag( NAMESPACE, tagName );
489 }
490
491
492
493
494
495
496
497
498
499
500 private void writeExecutionConfigurationScan( ExecutionConfigurationScan executionConfigurationScan, String tagName, XmlSerializer serializer )
501 throws java.io.IOException
502 {
503 serializer.startTag( NAMESPACE, tagName );
504 if ( executionConfigurationScan.isIgnoreParentConfig() != false )
505 {
506 serializer.attribute( NAMESPACE, "ignoreParentConfig", String.valueOf( executionConfigurationScan.isIgnoreParentConfig() ) );
507 }
508 if ( ( executionConfigurationScan.getExecIds() != null ) && ( executionConfigurationScan.getExecIds().size() > 0 ) )
509 {
510 serializer.startTag( NAMESPACE, "execIds" );
511 for ( Iterator iter = executionConfigurationScan.getExecIds().iterator(); iter.hasNext(); )
512 {
513 String execId = (String) iter.next();
514 serializer.startTag( NAMESPACE, "execId" ).text( execId ).endTag( NAMESPACE, "execId" );
515 }
516 serializer.endTag( NAMESPACE, "execIds" );
517 }
518 if ( executionConfigurationScan.getDirScan() != null )
519 {
520 writeDirScanConfig( (DirScanConfig) executionConfigurationScan.getDirScan(), "dirScan", serializer );
521 }
522 serializer.endTag( NAMESPACE, tagName );
523 }
524
525
526
527
528
529
530
531
532
533 private void writeExecutionControl( ExecutionControl executionControl, String tagName, XmlSerializer serializer )
534 throws java.io.IOException
535 {
536 serializer.startTag( NAMESPACE, tagName );
537 if ( executionControl.getRunAlways() != null )
538 {
539 writeExecutables( (Executables) executionControl.getRunAlways(), "runAlways", serializer );
540 }
541 if ( executionControl.getIgnoreMissing() != null )
542 {
543 writeExecutables( (Executables) executionControl.getIgnoreMissing(), "ignoreMissing", serializer );
544 }
545 if ( executionControl.getReconcile() != null )
546 {
547 writeReconcile( (Reconcile) executionControl.getReconcile(), "reconcile", serializer );
548 }
549 serializer.endTag( NAMESPACE, tagName );
550 }
551
552
553
554
555
556
557
558
559
560 private void writeExecutionIdsList( ExecutionIdsList executionIdsList, String tagName, XmlSerializer serializer )
561 throws java.io.IOException
562 {
563 serializer.startTag( NAMESPACE, tagName );
564 if ( executionIdsList.getGroupId() != null )
565 {
566 serializer.attribute( NAMESPACE, "groupId", executionIdsList.getGroupId() );
567 }
568 if ( executionIdsList.getArtifactId() != null )
569 {
570 serializer.attribute( NAMESPACE, "artifactId", executionIdsList.getArtifactId() );
571 }
572 if ( ( executionIdsList.getExecIds() != null ) && ( executionIdsList.getExecIds().size() > 0 ) )
573 {
574 serializer.startTag( NAMESPACE, "execIds" );
575 for ( Iterator iter = executionIdsList.getExecIds().iterator(); iter.hasNext(); )
576 {
577 String execId = (String) iter.next();
578 serializer.startTag( NAMESPACE, "execId" ).text( execId ).endTag( NAMESPACE, "execId" );
579 }
580 serializer.endTag( NAMESPACE, "execIds" );
581 }
582 serializer.endTag( NAMESPACE, tagName );
583 }
584
585
586
587
588
589
590
591
592
593 private void writeGoalId( GoalId goalId, String tagName, XmlSerializer serializer )
594 throws java.io.IOException
595 {
596 serializer.startTag( NAMESPACE, tagName );
597 if ( goalId.getGoal() != null )
598 {
599 serializer.attribute( NAMESPACE, "goal", goalId.getGoal() );
600 }
601 if ( goalId.getGroupId() != null )
602 {
603 serializer.attribute( NAMESPACE, "groupId", goalId.getGroupId() );
604 }
605 if ( goalId.getArtifactId() != null )
606 {
607 serializer.attribute( NAMESPACE, "artifactId", goalId.getArtifactId() );
608 }
609 serializer.endTag( NAMESPACE, tagName );
610 }
611
612
613
614
615
616
617
618
619
620 private void writeGoalReconciliation( GoalReconciliation goalReconciliation, String tagName, XmlSerializer serializer )
621 throws java.io.IOException
622 {
623 serializer.startTag( NAMESPACE, tagName );
624 if ( goalReconciliation.getGoal() != null )
625 {
626 serializer.attribute( NAMESPACE, "goal", goalReconciliation.getGoal() );
627 }
628 if ( goalReconciliation.getGroupId() != null )
629 {
630 serializer.attribute( NAMESPACE, "groupId", goalReconciliation.getGroupId() );
631 }
632 if ( goalReconciliation.getArtifactId() != null )
633 {
634 serializer.attribute( NAMESPACE, "artifactId", goalReconciliation.getArtifactId() );
635 }
636 if ( ( goalReconciliation.getReconciles() != null ) && ( goalReconciliation.getReconciles().size() > 0 ) )
637 {
638 serializer.startTag( NAMESPACE, "reconciles" );
639 for ( Iterator iter = goalReconciliation.getReconciles().iterator(); iter.hasNext(); )
640 {
641 TrackedProperty o = (TrackedProperty) iter.next();
642 writeTrackedProperty( o, "reconcile", serializer );
643 }
644 serializer.endTag( NAMESPACE, "reconciles" );
645 }
646 if ( ( goalReconciliation.getLogs() != null ) && ( goalReconciliation.getLogs().size() > 0 ) )
647 {
648 serializer.startTag( NAMESPACE, "logs" );
649 for ( Iterator iter = goalReconciliation.getLogs().iterator(); iter.hasNext(); )
650 {
651 PropertyName o = (PropertyName) iter.next();
652 writePropertyName( o, "log", serializer );
653 }
654 serializer.endTag( NAMESPACE, "logs" );
655 }
656 if ( ( goalReconciliation.getNologs() != null ) && ( goalReconciliation.getNologs().size() > 0 ) )
657 {
658 serializer.startTag( NAMESPACE, "nologs" );
659 for ( Iterator iter = goalReconciliation.getNologs().iterator(); iter.hasNext(); )
660 {
661 PropertyName o = (PropertyName) iter.next();
662 writePropertyName( o, "nolog", serializer );
663 }
664 serializer.endTag( NAMESPACE, "nologs" );
665 }
666 if ( goalReconciliation.isLogAll() != true )
667 {
668 serializer.startTag( NAMESPACE, "logAll" ).text( String.valueOf( goalReconciliation.isLogAll() ) ).endTag( NAMESPACE, "logAll" );
669 }
670 serializer.endTag( NAMESPACE, tagName );
671 }
672
673
674
675
676
677
678
679
680
681 private void writeGoalsList( GoalsList goalsList, String tagName, XmlSerializer serializer )
682 throws java.io.IOException
683 {
684 serializer.startTag( NAMESPACE, tagName );
685 if ( goalsList.getGroupId() != null )
686 {
687 serializer.attribute( NAMESPACE, "groupId", goalsList.getGroupId() );
688 }
689 if ( goalsList.getArtifactId() != null )
690 {
691 serializer.attribute( NAMESPACE, "artifactId", goalsList.getArtifactId() );
692 }
693 if ( ( goalsList.getGoals() != null ) && ( goalsList.getGoals().size() > 0 ) )
694 {
695 serializer.startTag( NAMESPACE, "goals" );
696 for ( Iterator iter = goalsList.getGoals().iterator(); iter.hasNext(); )
697 {
698 String goal = (String) iter.next();
699 serializer.startTag( NAMESPACE, "goal" ).text( goal ).endTag( NAMESPACE, "goal" );
700 }
701 serializer.endTag( NAMESPACE, "goals" );
702 }
703 serializer.endTag( NAMESPACE, tagName );
704 }
705
706
707
708
709
710
711
712
713
714 private void writeInclude( Include include, String tagName, XmlSerializer serializer )
715 throws java.io.IOException
716 {
717 serializer.startTag( NAMESPACE, tagName );
718 if ( include.isRecursive() != true )
719 {
720 serializer.attribute( NAMESPACE, "recursive", String.valueOf( include.isRecursive() ) );
721 }
722 if ( include.getGlob() != null )
723 {
724 serializer.attribute( NAMESPACE, "glob", include.getGlob() );
725 }
726 serializer.text( include.getValue() );
727 serializer.endTag( NAMESPACE, tagName );
728 }
729
730
731
732
733
734
735
736
737
738 private void writeInput( Input input, String tagName, XmlSerializer serializer )
739 throws java.io.IOException
740 {
741 serializer.startTag( NAMESPACE, tagName );
742 if ( input.getGlobal() != null )
743 {
744 writePathSet( (PathSet) input.getGlobal(), "global", serializer );
745 }
746 if ( ( input.getPlugins() != null ) && ( input.getPlugins().size() > 0 ) )
747 {
748 serializer.startTag( NAMESPACE, "plugins" );
749 for ( Iterator iter = input.getPlugins().iterator(); iter.hasNext(); )
750 {
751 PluginConfigurationScan o = (PluginConfigurationScan) iter.next();
752 writePluginConfigurationScan( o, "plugin", serializer );
753 }
754 serializer.endTag( NAMESPACE, "plugins" );
755 }
756 serializer.endTag( NAMESPACE, tagName );
757 }
758
759
760
761
762
763
764
765
766
767 private void writeLocal( Local local, String tagName, XmlSerializer serializer )
768 throws java.io.IOException
769 {
770 serializer.startTag( NAMESPACE, tagName );
771 if ( local.getLocation() != null )
772 {
773 serializer.startTag( NAMESPACE, "location" ).text( local.getLocation() ).endTag( NAMESPACE, "location" );
774 }
775 if ( local.getMaxBuildsCached() != 3 )
776 {
777 serializer.startTag( NAMESPACE, "maxBuildsCached" ).text( String.valueOf( local.getMaxBuildsCached() ) ).endTag( NAMESPACE, "maxBuildsCached" );
778 }
779 serializer.endTag( NAMESPACE, tagName );
780 }
781
782
783
784
785
786
787
788
789
790 private void writeMultiModule( MultiModule multiModule, String tagName, XmlSerializer serializer )
791 throws java.io.IOException
792 {
793 serializer.startTag( NAMESPACE, tagName );
794 if ( multiModule.getDiscovery() != null )
795 {
796 writeDiscovery( (Discovery) multiModule.getDiscovery(), "discovery", serializer );
797 }
798 serializer.endTag( NAMESPACE, tagName );
799 }
800
801
802
803
804
805
806
807
808
809 private void writeOutput( Output output, String tagName, XmlSerializer serializer )
810 throws java.io.IOException
811 {
812 serializer.startTag( NAMESPACE, tagName );
813 if ( output.getExclude() != null )
814 {
815 writeOutputExclude( (OutputExclude) output.getExclude(), "exclude", serializer );
816 }
817 serializer.endTag( NAMESPACE, tagName );
818 }
819
820
821
822
823
824
825
826
827
828 private void writeOutputExclude( OutputExclude outputExclude, String tagName, XmlSerializer serializer )
829 throws java.io.IOException
830 {
831 serializer.startTag( NAMESPACE, tagName );
832 if ( ( outputExclude.getPatterns() != null ) && ( outputExclude.getPatterns().size() > 0 ) )
833 {
834 serializer.startTag( NAMESPACE, "patterns" );
835 for ( Iterator iter = outputExclude.getPatterns().iterator(); iter.hasNext(); )
836 {
837 String pattern = (String) iter.next();
838 serializer.startTag( NAMESPACE, "pattern" ).text( pattern ).endTag( NAMESPACE, "pattern" );
839 }
840 serializer.endTag( NAMESPACE, "patterns" );
841 }
842 serializer.endTag( NAMESPACE, tagName );
843 }
844
845
846
847
848
849
850
851
852
853 private void writePathSet( PathSet pathSet, String tagName, XmlSerializer serializer )
854 throws java.io.IOException
855 {
856 serializer.startTag( NAMESPACE, tagName );
857 if ( ( pathSet.getGlob() != null ) && !pathSet.getGlob().equals( "*" ) )
858 {
859 serializer.startTag( NAMESPACE, "glob" ).text( pathSet.getGlob() ).endTag( NAMESPACE, "glob" );
860 }
861 if ( ( pathSet.getIncludes() != null ) && ( pathSet.getIncludes().size() > 0 ) )
862 {
863 serializer.startTag( NAMESPACE, "includes" );
864 for ( Iterator iter = pathSet.getIncludes().iterator(); iter.hasNext(); )
865 {
866 Include o = (Include) iter.next();
867 writeInclude( o, "include", serializer );
868 }
869 serializer.endTag( NAMESPACE, "includes" );
870 }
871 if ( ( pathSet.getExcludes() != null ) && ( pathSet.getExcludes().size() > 0 ) )
872 {
873 serializer.startTag( NAMESPACE, "excludes" );
874 for ( Iterator iter = pathSet.getExcludes().iterator(); iter.hasNext(); )
875 {
876 Exclude o = (Exclude) iter.next();
877 writeExclude( o, "exclude", serializer );
878 }
879 serializer.endTag( NAMESPACE, "excludes" );
880 }
881 serializer.endTag( NAMESPACE, tagName );
882 }
883
884
885
886
887
888
889
890
891
892
893 private void writePluginConfigurationScan( PluginConfigurationScan pluginConfigurationScan, String tagName, XmlSerializer serializer )
894 throws java.io.IOException
895 {
896 serializer.startTag( NAMESPACE, tagName );
897 if ( pluginConfigurationScan.isExcludeDependencies() != false )
898 {
899 serializer.attribute( NAMESPACE, "excludeDependencies", String.valueOf( pluginConfigurationScan.isExcludeDependencies() ) );
900 }
901 if ( pluginConfigurationScan.getGroupId() != null )
902 {
903 serializer.attribute( NAMESPACE, "groupId", pluginConfigurationScan.getGroupId() );
904 }
905 if ( pluginConfigurationScan.getArtifactId() != null )
906 {
907 serializer.attribute( NAMESPACE, "artifactId", pluginConfigurationScan.getArtifactId() );
908 }
909 if ( pluginConfigurationScan.getEffectivePom() != null )
910 {
911 writeEffectivePom( (EffectivePom) pluginConfigurationScan.getEffectivePom(), "effectivePom", serializer );
912 }
913 if ( pluginConfigurationScan.getDirScan() != null )
914 {
915 writeDirScanConfig( (DirScanConfig) pluginConfigurationScan.getDirScan(), "dirScan", serializer );
916 }
917 if ( ( pluginConfigurationScan.getExecutions() != null ) && ( pluginConfigurationScan.getExecutions().size() > 0 ) )
918 {
919 serializer.startTag( NAMESPACE, "executions" );
920 for ( Iterator iter = pluginConfigurationScan.getExecutions().iterator(); iter.hasNext(); )
921 {
922 ExecutionConfigurationScan o = (ExecutionConfigurationScan) iter.next();
923 writeExecutionConfigurationScan( o, "execution", serializer );
924 }
925 serializer.endTag( NAMESPACE, "executions" );
926 }
927 serializer.endTag( NAMESPACE, tagName );
928 }
929
930
931
932
933
934
935
936
937
938 private void writePluginSet( PluginSet pluginSet, String tagName, XmlSerializer serializer )
939 throws java.io.IOException
940 {
941 serializer.startTag( NAMESPACE, tagName );
942 if ( pluginSet.getGroupId() != null )
943 {
944 serializer.attribute( NAMESPACE, "groupId", pluginSet.getGroupId() );
945 }
946 if ( pluginSet.getArtifactId() != null )
947 {
948 serializer.attribute( NAMESPACE, "artifactId", pluginSet.getArtifactId() );
949 }
950 serializer.endTag( NAMESPACE, tagName );
951 }
952
953
954
955
956
957
958
959
960
961 private void writeProjectVersioning( ProjectVersioning projectVersioning, String tagName, XmlSerializer serializer )
962 throws java.io.IOException
963 {
964 serializer.startTag( NAMESPACE, tagName );
965 if ( projectVersioning.isAdjustMetaInf() != false )
966 {
967 serializer.attribute( NAMESPACE, "adjustMetaInf", String.valueOf( projectVersioning.isAdjustMetaInf() ) );
968 }
969 if ( projectVersioning.isCalculateProjectVersionChecksum() != false )
970 {
971 serializer.attribute( NAMESPACE, "calculateProjectVersionChecksum", String.valueOf( projectVersioning.isCalculateProjectVersionChecksum() ) );
972 }
973 serializer.endTag( NAMESPACE, tagName );
974 }
975
976
977
978
979
980
981
982
983
984 private void writePropertyName( PropertyName propertyName, String tagName, XmlSerializer serializer )
985 throws java.io.IOException
986 {
987 serializer.startTag( NAMESPACE, tagName );
988 if ( propertyName.getPropertyName() != null )
989 {
990 serializer.attribute( NAMESPACE, "propertyName", propertyName.getPropertyName() );
991 }
992 serializer.text( propertyName.getValue() );
993 serializer.endTag( NAMESPACE, tagName );
994 }
995
996
997
998
999
1000
1001
1002
1003
1004 private void writeReconcile( Reconcile reconcile, String tagName, XmlSerializer serializer )
1005 throws java.io.IOException
1006 {
1007 serializer.startTag( NAMESPACE, tagName );
1008 if ( reconcile.isLogAllProperties() != true )
1009 {
1010 serializer.attribute( NAMESPACE, "logAllProperties", String.valueOf( reconcile.isLogAllProperties() ) );
1011 }
1012 if ( ( reconcile.getPlugins() != null ) && ( reconcile.getPlugins().size() > 0 ) )
1013 {
1014 serializer.startTag( NAMESPACE, "plugins" );
1015 for ( Iterator iter = reconcile.getPlugins().iterator(); iter.hasNext(); )
1016 {
1017 GoalReconciliation o = (GoalReconciliation) iter.next();
1018 writeGoalReconciliation( o, "plugin", serializer );
1019 }
1020 serializer.endTag( NAMESPACE, "plugins" );
1021 }
1022 serializer.endTag( NAMESPACE, tagName );
1023 }
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033 private void writeRemote( Remote remote, String tagName, XmlSerializer serializer )
1034 throws java.io.IOException
1035 {
1036 serializer.startTag( NAMESPACE, tagName );
1037 if ( remote.isEnabled() != true )
1038 {
1039 serializer.attribute( NAMESPACE, "enabled", String.valueOf( remote.isEnabled() ) );
1040 }
1041 if ( remote.isSaveToRemote() != false )
1042 {
1043 serializer.attribute( NAMESPACE, "saveToRemote", String.valueOf( remote.isSaveToRemote() ) );
1044 }
1045 if ( ( remote.getTransport() != null ) && !remote.getTransport().equals( "resolver" ) )
1046 {
1047 serializer.attribute( NAMESPACE, "transport", remote.getTransport() );
1048 }
1049 if ( ( remote.getId() != null ) && !remote.getId().equals( "cache" ) )
1050 {
1051 serializer.attribute( NAMESPACE, "id", remote.getId() );
1052 }
1053 if ( remote.getUrl() != null )
1054 {
1055 serializer.startTag( NAMESPACE, "url" ).text( remote.getUrl() ).endTag( NAMESPACE, "url" );
1056 }
1057 serializer.endTag( NAMESPACE, tagName );
1058 }
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068 private void writeTagExclude( TagExclude tagExclude, String tagName, XmlSerializer serializer )
1069 throws java.io.IOException
1070 {
1071 serializer.startTag( NAMESPACE, tagName );
1072 if ( tagExclude.getTagName() != null )
1073 {
1074 serializer.attribute( NAMESPACE, "tagName", tagExclude.getTagName() );
1075 }
1076 serializer.endTag( NAMESPACE, tagName );
1077 }
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087 private void writeTagScanConfig( TagScanConfig tagScanConfig, String tagName, XmlSerializer serializer )
1088 throws java.io.IOException
1089 {
1090 serializer.startTag( NAMESPACE, tagName );
1091 if ( tagScanConfig.isRecursive() != true )
1092 {
1093 serializer.attribute( NAMESPACE, "recursive", String.valueOf( tagScanConfig.isRecursive() ) );
1094 }
1095 if ( ( tagScanConfig.getGlob() != null ) && !tagScanConfig.getGlob().equals( "*" ) )
1096 {
1097 serializer.attribute( NAMESPACE, "glob", tagScanConfig.getGlob() );
1098 }
1099 if ( tagScanConfig.getTagName() != null )
1100 {
1101 serializer.attribute( NAMESPACE, "tagName", tagScanConfig.getTagName() );
1102 }
1103 serializer.endTag( NAMESPACE, tagName );
1104 }
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114 private void writeTrackedProperty( TrackedProperty trackedProperty, String tagName, XmlSerializer serializer )
1115 throws java.io.IOException
1116 {
1117 serializer.startTag( NAMESPACE, tagName );
1118 if ( trackedProperty.getPropertyName() != null )
1119 {
1120 serializer.attribute( NAMESPACE, "propertyName", trackedProperty.getPropertyName() );
1121 }
1122 if ( trackedProperty.getSkipValue() != null )
1123 {
1124 serializer.attribute( NAMESPACE, "skipValue", trackedProperty.getSkipValue() );
1125 }
1126 if ( trackedProperty.getDefaultValue() != null )
1127 {
1128 serializer.attribute( NAMESPACE, "defaultValue", trackedProperty.getDefaultValue() );
1129 }
1130 serializer.text( trackedProperty.getValue() );
1131 serializer.endTag( NAMESPACE, tagName );
1132 }
1133
1134 }