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