1 package org.apache.maven.model.interpolation;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.HashMap;
24 import java.util.List;
25 import java.util.ListIterator;
26 import java.util.Map;
27 import java.util.Properties;
28
29 import javax.inject.Named;
30 import javax.inject.Singleton;
31
32 import org.apache.maven.model.Activation;
33 import org.apache.maven.model.ActivationFile;
34 import org.apache.maven.model.ActivationOS;
35 import org.apache.maven.model.ActivationProperty;
36 import org.apache.maven.model.Build;
37 import org.apache.maven.model.BuildBase;
38 import org.apache.maven.model.CiManagement;
39 import org.apache.maven.model.Contributor;
40 import org.apache.maven.model.Dependency;
41 import org.apache.maven.model.DependencyManagement;
42 import org.apache.maven.model.Developer;
43 import org.apache.maven.model.DistributionManagement;
44 import org.apache.maven.model.Exclusion;
45 import org.apache.maven.model.Extension;
46 import org.apache.maven.model.IssueManagement;
47 import org.apache.maven.model.License;
48 import org.apache.maven.model.MailingList;
49 import org.apache.maven.model.Model;
50 import org.apache.maven.model.ModelBase;
51 import org.apache.maven.model.Notifier;
52 import org.apache.maven.model.Organization;
53 import org.apache.maven.model.Parent;
54 import org.apache.maven.model.Plugin;
55 import org.apache.maven.model.PluginExecution;
56 import org.apache.maven.model.PluginManagement;
57 import org.apache.maven.model.Prerequisites;
58 import org.apache.maven.model.Profile;
59 import org.apache.maven.model.Relocation;
60 import org.apache.maven.model.ReportPlugin;
61 import org.apache.maven.model.ReportSet;
62 import org.apache.maven.model.Reporting;
63 import org.apache.maven.model.Repository;
64 import org.apache.maven.model.RepositoryBase;
65 import org.apache.maven.model.RepositoryPolicy;
66 import org.apache.maven.model.Resource;
67 import org.apache.maven.model.Scm;
68 import org.apache.maven.model.Site;
69 import org.apache.maven.model.building.ModelBuildingRequest;
70 import org.apache.maven.model.building.ModelProblem.Severity;
71 import org.apache.maven.model.building.ModelProblem.Version;
72 import org.apache.maven.model.building.ModelProblemCollector;
73 import org.apache.maven.model.building.ModelProblemCollectorRequest;
74 import org.codehaus.plexus.interpolation.InterpolationException;
75 import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
76 import org.codehaus.plexus.interpolation.RecursionInterceptor;
77 import org.codehaus.plexus.interpolation.StringSearchInterpolator;
78 import org.codehaus.plexus.interpolation.ValueSource;
79 import org.codehaus.plexus.util.xml.Xpp3Dom;
80
81
82
83
84 @Named
85 @Singleton
86 public class StringVisitorModelInterpolator
87 extends AbstractStringBasedModelInterpolator
88 {
89
90 interface InnerInterpolator
91 {
92 String interpolate( String value );
93 }
94
95 @Override
96 public Model interpolateModel( Model model, File projectDir, ModelBuildingRequest config,
97 ModelProblemCollector problems )
98 {
99 List<? extends ValueSource> valueSources = createValueSources( model, projectDir, config, problems );
100 List<? extends InterpolationPostProcessor> postProcessors =
101 createPostProcessors( model, projectDir, config );
102
103 InnerInterpolator innerInterpolator = createInterpolator( valueSources, postProcessors, problems );
104
105 new ModelVisitor( innerInterpolator ).visit( model );
106
107 return model;
108 }
109
110 private InnerInterpolator createInterpolator( List<? extends ValueSource> valueSources,
111 List<? extends InterpolationPostProcessor> postProcessors,
112 final ModelProblemCollector problems )
113 {
114 final Map<String, String> cache = new HashMap<>();
115 final StringSearchInterpolator interpolator = new StringSearchInterpolator();
116 interpolator.setCacheAnswers( true );
117 for ( ValueSource vs : valueSources )
118 {
119 interpolator.addValueSource( vs );
120 }
121 for ( InterpolationPostProcessor postProcessor : postProcessors )
122 {
123 interpolator.addPostProcessor( postProcessor );
124 }
125 final RecursionInterceptor recursionInterceptor = createRecursionInterceptor();
126 return new InnerInterpolator()
127 {
128 @Override
129 public String interpolate( String value )
130 {
131 if ( value != null && value.contains( "${" ) )
132 {
133 String c = cache.get( value );
134 if ( c == null )
135 {
136 try
137 {
138 c = interpolator.interpolate( value, recursionInterceptor );
139 }
140 catch ( InterpolationException e )
141 {
142 problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
143 .setMessage( e.getMessage() ).setException( e ) );
144 }
145 cache.put( value, c );
146 }
147 return c;
148 }
149 return value;
150 }
151 };
152 }
153
154 @SuppressWarnings( "StringEquality" )
155 private static final class ModelVisitor
156 {
157 private final InnerInterpolator interpolator;
158
159 ModelVisitor( InnerInterpolator interpolator )
160 {
161 this.interpolator = interpolator;
162 }
163
164 void visit( Model model )
165 {
166 if ( model != null )
167 {
168 visit( (ModelBase) model );
169
170 String orgModelVersion = model.getModelVersion();
171 String intModelVersion = interpolate( orgModelVersion );
172 if ( orgModelVersion != intModelVersion )
173 {
174 model.setModelVersion( intModelVersion );
175 }
176 visit( model.getParent() );
177
178 String orgGroupId = model.getGroupId();
179 String intGroupId = interpolate( orgGroupId );
180 if ( orgGroupId != intGroupId )
181 {
182 model.setGroupId( intGroupId );
183 }
184
185 String orgArtifactId = model.getArtifactId();
186 String intArtifactId = interpolate( orgArtifactId );
187 if ( orgArtifactId != intArtifactId )
188 {
189 model.setArtifactId( intArtifactId );
190 }
191
192 String orgVersion = model.getVersion();
193 String intVersion = interpolate( orgVersion );
194 if ( orgVersion != intVersion )
195 {
196 model.setVersion( intVersion );
197 }
198
199
200 String orgPackaging = model.getPackaging();
201 String intPackaging = interpolate( orgPackaging );
202 if ( orgPackaging != intPackaging )
203 {
204 model.setPackaging( intPackaging );
205 }
206
207 String orgName = model.getName();
208 String intName = interpolate( orgName );
209 if ( orgName != intName )
210 {
211 model.setName( intName );
212 }
213
214 String orgDescription = model.getDescription();
215 String intDescription = interpolate( orgDescription );
216 if ( orgDescription != intDescription )
217 {
218 model.setDescription( intDescription );
219 }
220
221 String orgUrl = model.getUrl();
222 String intUrl = interpolate( orgUrl );
223 if ( orgUrl != intUrl )
224 {
225 model.setUrl( intUrl );
226 }
227
228 String orgChildProjectUrlInheritAppendPath = model.getChildProjectUrlInheritAppendPath();
229 String intChildProjectUrlInheritAppendPath = interpolate( orgChildProjectUrlInheritAppendPath );
230 if ( orgChildProjectUrlInheritAppendPath != intChildProjectUrlInheritAppendPath )
231 {
232 model.setChildProjectUrlInheritAppendPath( intChildProjectUrlInheritAppendPath );
233 }
234
235 String orgInceptionYear = model.getInceptionYear();
236 String intInceptionYear = interpolate( orgInceptionYear );
237 if ( orgInceptionYear != intInceptionYear )
238 {
239 model.setInceptionYear( intInceptionYear );
240 }
241 visit( model.getOrganization() );
242 for ( License license : model.getLicenses() )
243 {
244 visit( license );
245 }
246 for ( Developer developer : model.getDevelopers() )
247 {
248 visit( developer );
249 }
250 for ( Contributor contributor : model.getContributors() )
251 {
252 visit( contributor );
253 }
254 for ( MailingList mailingList : model.getMailingLists() )
255 {
256 visit( mailingList );
257 }
258 visit( model.getPrerequisites() );
259 visit( model.getScm() );
260 visit( model.getIssueManagement() );
261 visit( model.getCiManagement() );
262 visit( model.getBuild() );
263 for ( Profile profile : model.getProfiles() )
264 {
265 visit( profile );
266 }
267
268 }
269 }
270
271 private void visit( Parent parent )
272 {
273 if ( parent != null )
274 {
275 String org, val;
276
277 org = parent.getGroupId();
278 val = interpolate( org );
279 if ( org != val )
280 {
281 parent.setGroupId( val );
282 }
283
284 org = parent.getArtifactId();
285 val = interpolate( org );
286 if ( org != val )
287 {
288 parent.setArtifactId( val );
289 }
290
291 org = parent.getVersion();
292 val = interpolate( org );
293 if ( org != val )
294 {
295 parent.setVersion( val );
296 }
297
298 org = parent.getRelativePath();
299 val = interpolate( org );
300 if ( org != val )
301 {
302 parent.setRelativePath( val );
303 }
304 }
305 }
306
307 private void visit( Organization organization )
308 {
309 if ( organization != null )
310 {
311 String org, val;
312
313 org = organization.getName();
314 val = interpolate( org );
315 if ( org != val )
316 {
317 organization.setName( val );
318 }
319
320 org = organization.getUrl();
321 val = interpolate( org );
322 if ( org != val )
323 {
324 organization.setUrl( val );
325 }
326 }
327 }
328
329 private void visit( License license )
330 {
331 if ( license != null )
332 {
333 String org, val;
334
335 org = license.getName();
336 val = interpolate( org );
337 if ( org != val )
338 {
339 license.setName( val );
340 }
341
342 org = license.getUrl();
343 val = interpolate( org );
344 if ( org != val )
345 {
346 license.setUrl( val );
347 }
348
349 org = license.getDistribution();
350 val = interpolate( org );
351 if ( org != val )
352 {
353 license.setDistribution( val );
354 }
355
356 org = license.getComments();
357 val = interpolate( org );
358 if ( org != val )
359 {
360 license.setComments( val );
361 }
362 }
363 }
364
365 private void visit( Developer developer )
366 {
367 if ( developer != null )
368 {
369 String org, val;
370
371 visit( (Contributor) developer );
372
373 org = developer.getId();
374 val = interpolate( org );
375 if ( org != val )
376 {
377 developer.setId( val );
378 }
379 }
380 }
381
382 private void visit( Contributor contributor )
383 {
384 if ( contributor != null )
385 {
386 String org, val;
387
388 org = contributor.getName();
389 val = interpolate( org );
390 if ( org != val )
391 {
392 contributor.setName( val );
393 }
394
395 org = contributor.getEmail();
396 val = interpolate( org );
397 if ( org != val )
398 {
399 contributor.setEmail( val );
400 }
401
402 org = contributor.getUrl();
403 val = interpolate( org );
404 if ( org != val )
405 {
406 contributor.setUrl( val );
407 }
408
409 org = contributor.getOrganization();
410 val = interpolate( org );
411 if ( org != val )
412 {
413 contributor.setOrganization( val );
414 }
415
416 org = contributor.getOrganizationUrl();
417 val = interpolate( org );
418 if ( org != val )
419 {
420 contributor.setOrganizationUrl( val );
421 }
422
423 visit( contributor.getRoles() );
424 }
425 }
426
427 private void visit( MailingList mailingList )
428 {
429 if ( mailingList != null )
430 {
431 String org, val;
432
433 org = mailingList.getName();
434 val = interpolate( org );
435 if ( org != val )
436 {
437 mailingList.setName( val );
438 }
439
440 org = mailingList.getSubscribe();
441 val = interpolate( org );
442 if ( org != val )
443 {
444 mailingList.setSubscribe( val );
445 }
446
447 org = mailingList.getUnsubscribe();
448 val = interpolate( org );
449 if ( org != val )
450 {
451 mailingList.setUnsubscribe( val );
452 }
453
454 org = mailingList.getPost();
455 val = interpolate( org );
456 if ( org != val )
457 {
458 mailingList.setPost( val );
459 }
460
461 org = mailingList.getArchive();
462 val = interpolate( org );
463 if ( org != val )
464 {
465 mailingList.setArchive( val );
466 }
467 }
468 }
469
470 private void visit( Prerequisites prerequisites )
471 {
472 if ( prerequisites != null )
473 {
474 String org, val;
475
476 org = prerequisites.getMaven();
477 val = interpolate( org );
478 if ( org != val )
479 {
480 prerequisites.setMaven( val );
481 }
482 }
483 }
484
485 private void visit( Scm scm )
486 {
487 if ( scm != null )
488 {
489 String org, val;
490
491 org = scm.getConnection();
492 val = interpolate( org );
493 if ( org != val )
494 {
495 scm.setConnection( val );
496 }
497
498 org = scm.getDeveloperConnection();
499 val = interpolate( org );
500 if ( org != val )
501 {
502 scm.setDeveloperConnection( val );
503 }
504
505 org = scm.getTag();
506 val = interpolate( org );
507 if ( org != val )
508 {
509 scm.setTag( val );
510 }
511
512 org = scm.getUrl();
513 val = interpolate( org );
514 if ( org != val )
515 {
516 scm.setUrl( val );
517 }
518
519 org = scm.getChildScmConnectionInheritAppendPath();
520 val = interpolate( org );
521 if ( org != val )
522 {
523 scm.setChildScmConnectionInheritAppendPath( val );
524 }
525
526 org = scm.getChildScmDeveloperConnectionInheritAppendPath();
527 val = interpolate( org );
528 if ( org != val )
529 {
530 scm.setChildScmDeveloperConnectionInheritAppendPath( val );
531 }
532
533 org = scm.getChildScmUrlInheritAppendPath();
534 val = interpolate( org );
535 if ( org != val )
536 {
537 scm.setChildScmUrlInheritAppendPath( val );
538 }
539 }
540 }
541
542 private void visit( IssueManagement issueManagement )
543 {
544 if ( issueManagement != null )
545 {
546 String org, val;
547
548 org = issueManagement.getSystem();
549 val = interpolate( org );
550 if ( org != val )
551 {
552 issueManagement.setSystem( val );
553 }
554
555 org = issueManagement.getUrl();
556 val = interpolate( org );
557 if ( org != val )
558 {
559 issueManagement.setUrl( val );
560 }
561 }
562 }
563
564 private void visit( CiManagement ciManagement )
565 {
566 if ( ciManagement != null )
567 {
568 String org, val;
569
570 org = ciManagement.getSystem();
571 val = interpolate( org );
572 if ( org != val )
573 {
574 ciManagement.setSystem( val );
575 }
576
577 org = ciManagement.getUrl();
578 val = interpolate( org );
579 if ( org != val )
580 {
581 ciManagement.setUrl( val );
582 }
583
584 for ( Notifier notifier : ciManagement.getNotifiers() )
585 {
586 visit( notifier );
587 }
588 }
589 }
590
591 private void visit( Notifier notifier )
592 {
593 if ( notifier != null )
594 {
595 String org, val;
596
597 org = notifier.getType();
598 val = interpolate( org );
599 if ( org != val )
600 {
601 notifier.setType( val );
602 }
603
604 visit( notifier.getConfiguration() );
605 }
606 }
607
608 private void visit( BuildBase build )
609 {
610 if ( build != null )
611 {
612 String org, val;
613
614 for ( Plugin plugin : build.getPlugins() )
615 {
616 visit( plugin );
617 }
618
619 visit( build.getPluginManagement() );
620
621 org = build.getDefaultGoal();
622 val = interpolate( org );
623 if ( org != val )
624 {
625 build.setDefaultGoal( val );
626 }
627
628 for ( Resource resource : build.getResources() )
629 {
630 visit( resource );
631 }
632
633 for ( Resource resource : build.getTestResources() )
634 {
635 visit( resource );
636 }
637
638 org = build.getDirectory();
639 val = interpolate( org );
640 if ( org != val )
641 {
642 build.setDirectory( val );
643 }
644
645 org = build.getFinalName();
646 val = interpolate( org );
647 if ( org != val )
648 {
649 build.setFinalName( val );
650 }
651
652 visit( build.getFilters() );
653 }
654 }
655
656 private void visit( PluginManagement pluginManagement )
657 {
658 if ( pluginManagement != null )
659 {
660 for ( Plugin plugin : pluginManagement.getPlugins() )
661 {
662 visit( plugin );
663 }
664 }
665 }
666
667 private void visit( Build build )
668 {
669 if ( build != null )
670 {
671 String org, val;
672
673 visit( (BuildBase) build );
674
675 org = build.getSourceDirectory();
676 val = interpolate( org );
677 if ( org != val )
678 {
679 build.setSourceDirectory( val );
680 }
681
682 org = build.getScriptSourceDirectory();
683 val = interpolate( org );
684 if ( org != val )
685 {
686 build.setScriptSourceDirectory( val );
687 }
688
689 org = build.getTestSourceDirectory();
690 val = interpolate( org );
691 if ( org != val )
692 {
693 build.setTestSourceDirectory( val );
694 }
695
696 org = build.getOutputDirectory();
697 val = interpolate( org );
698 if ( org != val )
699 {
700 build.setOutputDirectory( val );
701 }
702
703 org = build.getTestOutputDirectory();
704 val = interpolate( org );
705 if ( org != val )
706 {
707 build.setTestOutputDirectory( val );
708 }
709
710 for ( Extension extension : build.getExtensions() )
711 {
712 visit( extension );
713 }
714 }
715 }
716
717 private void visit( Resource resource )
718 {
719 if ( resource != null )
720 {
721 String org, val;
722
723 visit( resource.getIncludes() );
724
725 visit( resource.getExcludes() );
726
727 org = resource.getDirectory();
728 val = interpolate( org );
729 if ( org != val )
730 {
731 resource.setDirectory( val );
732 }
733
734 org = resource.getTargetPath();
735 val = interpolate( org );
736 if ( org != val )
737 {
738 resource.setTargetPath( val );
739 }
740
741 org = resource.getFiltering();
742 val = interpolate( org );
743 if ( org != val )
744 {
745 resource.setFiltering( val );
746 }
747 }
748 }
749
750 private void visit( Plugin plugin )
751 {
752 if ( plugin != null )
753 {
754 String org, val;
755
756 org = plugin.getInherited();
757 val = interpolate( org );
758 if ( org != val )
759 {
760 plugin.setInherited( val );
761 }
762
763 visit( (Xpp3Dom) plugin.getConfiguration() );
764
765 org = plugin.getGroupId();
766 val = interpolate( org );
767 if ( org != val )
768 {
769 plugin.setGroupId( val );
770 }
771
772 org = plugin.getArtifactId();
773 val = interpolate( org );
774 if ( org != val )
775 {
776 plugin.setArtifactId( val );
777 }
778
779 org = plugin.getVersion();
780 val = interpolate( org );
781 if ( org != val )
782 {
783 plugin.setVersion( val );
784 }
785
786 org = plugin.getExtensions();
787 val = interpolate( org );
788 if ( org != val )
789 {
790 plugin.setExtensions( val );
791 }
792
793 for ( PluginExecution execution : plugin.getExecutions() )
794 {
795 visit( execution );
796 }
797
798 for ( Dependency dependency : plugin.getDependencies() )
799 {
800 visit( dependency );
801 }
802 }
803 }
804
805 private void visit( PluginExecution execution )
806 {
807 if ( execution != null )
808 {
809 String org, val;
810
811 org = execution.getInherited();
812 val = interpolate( org );
813 if ( org != val )
814 {
815 execution.setInherited( val );
816 }
817
818 visit( (Xpp3Dom) execution.getConfiguration() );
819
820 org = execution.getId();
821 val = interpolate( org );
822 if ( org != val )
823 {
824 execution.setId( val );
825 }
826
827 org = execution.getPhase();
828 val = interpolate( org );
829 if ( org != val )
830 {
831 execution.setPhase( val );
832 }
833
834 visit( execution.getGoals() );
835 }
836 }
837
838 private void visit( Xpp3Dom dom )
839 {
840 if ( dom != null )
841 {
842 String org, val;
843
844 org = dom.getValue();
845 val = interpolate( org );
846 if ( org != val )
847 {
848 dom.setValue( val );
849 }
850
851 for ( String attr : dom.getAttributeNames() )
852 {
853 org = dom.getAttribute( attr );
854 val = interpolate( org );
855 if ( org != val )
856 {
857 dom.setAttribute( attr, val );
858 }
859 }
860
861 for ( int i = 0, l = dom.getChildCount(); i < l; i++ )
862 {
863 visit( dom.getChild( i ) );
864 }
865 }
866 }
867
868 private void visit( Extension extension )
869 {
870 if ( extension != null )
871 {
872 String org, val;
873
874 org = extension.getGroupId();
875 val = interpolate( org );
876 if ( org != val )
877 {
878 extension.setGroupId( val );
879 }
880
881 org = extension.getArtifactId();
882 val = interpolate( org );
883 if ( org != val )
884 {
885 extension.setArtifactId( val );
886 }
887
888 org = extension.getVersion();
889 val = interpolate( org );
890 if ( org != val )
891 {
892 extension.setVersion( val );
893 }
894 }
895 }
896
897 private void visit( Profile profile )
898 {
899 if ( profile != null )
900 {
901 String org, val;
902
903 visit( (ModelBase) profile );
904
905 org = profile.getId();
906 val = interpolate( org );
907 if ( org != val )
908 {
909 profile.setId( val );
910 }
911
912 visit( profile.getActivation() );
913
914 visit( profile.getBuild() );
915 }
916 }
917
918 private void visit( Activation activation )
919 {
920 if ( activation != null )
921 {
922 String org, val;
923
924 org = activation.getJdk();
925 val = interpolate( org );
926 if ( org != val )
927 {
928 activation.setJdk( val );
929 }
930
931 visit( activation.getOs() );
932
933 visit( activation.getProperty() );
934
935 visit( activation.getFile() );
936 }
937 }
938
939 private void visit( ActivationOS activationOS )
940 {
941 if ( activationOS != null )
942 {
943 String org, val;
944
945 org = activationOS.getName();
946 val = interpolate( org );
947 if ( org != val )
948 {
949 activationOS.setName( val );
950 }
951
952 org = activationOS.getFamily();
953 val = interpolate( org );
954 if ( org != val )
955 {
956 activationOS.setFamily( val );
957 }
958
959 org = activationOS.getArch();
960 val = interpolate( org );
961 if ( org != val )
962 {
963 activationOS.setArch( val );
964 }
965
966 org = activationOS.getVersion();
967 val = interpolate( org );
968 if ( org != val )
969 {
970 activationOS.setVersion( val );
971 }
972 }
973 }
974
975 private void visit( ActivationProperty activationProperty )
976 {
977 if ( activationProperty != null )
978 {
979 String org, val;
980
981 org = activationProperty.getName();
982 val = interpolate( org );
983 if ( org != val )
984 {
985 activationProperty.setName( val );
986 }
987
988 org = activationProperty.getValue();
989 val = interpolate( org );
990 if ( org != val )
991 {
992 activationProperty.setValue( val );
993 }
994 }
995 }
996
997 private void visit( ActivationFile activationFile )
998 {
999 if ( activationFile != null )
1000 {
1001 String org, val;
1002
1003 org = activationFile.getMissing();
1004 val = interpolate( org );
1005 if ( org != val )
1006 {
1007 activationFile.setMissing( val );
1008 }
1009
1010 org = activationFile.getExists();
1011 val = interpolate( org );
1012 if ( org != val )
1013 {
1014 activationFile.setExists( val );
1015 }
1016 }
1017 }
1018
1019 private void visit( ModelBase modelBase )
1020 {
1021 if ( modelBase != null )
1022 {
1023 visit( modelBase.getModules() );
1024 visit( modelBase.getDistributionManagement() );
1025 visit( modelBase.getProperties() );
1026 visit( modelBase.getDependencyManagement() );
1027 for ( Dependency dependency : modelBase.getDependencies() )
1028 {
1029 visit( dependency );
1030 }
1031 for ( Repository repository : modelBase.getRepositories() )
1032 {
1033 visit( repository );
1034 }
1035 for ( Repository repository : modelBase.getPluginRepositories() )
1036 {
1037 visit( repository );
1038 }
1039 visit( modelBase.getReporting() );
1040 }
1041 }
1042
1043 private void visit( DistributionManagement distributionManagement )
1044 {
1045 if ( distributionManagement != null )
1046 {
1047 String org, val;
1048
1049 visit( distributionManagement.getRepository() );
1050
1051 visit( distributionManagement.getSnapshotRepository() );
1052
1053 visit( distributionManagement.getSite() );
1054
1055 org = distributionManagement.getDownloadUrl();
1056 val = interpolate( org );
1057 if ( org != val )
1058 {
1059 distributionManagement.setDownloadUrl( val );
1060 }
1061
1062 visit( distributionManagement.getRelocation() );
1063 }
1064 }
1065
1066 private void visit( Site site )
1067 {
1068 if ( site != null )
1069 {
1070 String org, val;
1071
1072 org = site.getId();
1073 val = interpolate( org );
1074 if ( org != val )
1075 {
1076 site.setId( val );
1077 }
1078
1079 org = site.getName();
1080 val = interpolate( org );
1081 if ( org != val )
1082 {
1083 site.setName( val );
1084 }
1085
1086 org = site.getUrl();
1087 val = interpolate( org );
1088 if ( org != val )
1089 {
1090 site.setUrl( val );
1091 }
1092
1093 org = site.getChildSiteUrlInheritAppendPath();
1094 val = interpolate( org );
1095 if ( org != val )
1096 {
1097 site.setChildSiteUrlInheritAppendPath( val );
1098 }
1099 }
1100 }
1101
1102 private void visit( Relocation relocation )
1103 {
1104 if ( relocation != null )
1105 {
1106 String org, val;
1107
1108 org = relocation.getGroupId();
1109 val = interpolate( org );
1110 if ( org != val )
1111 {
1112 relocation.setGroupId( val );
1113 }
1114
1115 org = relocation.getArtifactId();
1116 val = interpolate( org );
1117 if ( org != val )
1118 {
1119 relocation.setArtifactId( val );
1120 }
1121
1122 org = relocation.getVersion();
1123 val = interpolate( org );
1124 if ( org != val )
1125 {
1126 relocation.setVersion( val );
1127 }
1128
1129 org = relocation.getMessage();
1130 val = interpolate( org );
1131 if ( org != val )
1132 {
1133 relocation.setMessage( val );
1134 }
1135 }
1136 }
1137
1138 private void visit( DependencyManagement dependencyManagement )
1139 {
1140 if ( dependencyManagement != null )
1141 {
1142
1143 for ( Dependency dependency : dependencyManagement.getDependencies() )
1144 {
1145 visit( dependency );
1146 }
1147 }
1148 }
1149
1150 private void visit( Repository repository )
1151 {
1152 if ( repository != null )
1153 {
1154 visit( (RepositoryBase) repository );
1155 visit( repository.getReleases() );
1156 visit( repository.getSnapshots() );
1157 }
1158 }
1159
1160 private void visit( RepositoryBase repositoryBase )
1161 {
1162 if ( repositoryBase != null )
1163 {
1164
1165 String orgId = repositoryBase.getId();
1166 String intId = interpolate( orgId );
1167 if ( orgId != intId )
1168 {
1169 repositoryBase.setId( intId );
1170 }
1171
1172 String orgName = repositoryBase.getName();
1173 String intName = interpolate( orgName );
1174 if ( orgName != intName )
1175 {
1176 repositoryBase.setName( intName );
1177 }
1178
1179 String orgUrl = repositoryBase.getUrl();
1180 String intUrl = interpolate( orgUrl );
1181 if ( orgUrl != intUrl )
1182 {
1183 repositoryBase.setUrl( intUrl );
1184 }
1185
1186 String orgLayout = repositoryBase.getLayout();
1187 String intLayout = interpolate( orgLayout );
1188 if ( orgLayout != intLayout )
1189 {
1190 repositoryBase.setLayout( intLayout );
1191 }
1192 }
1193 }
1194
1195 private void visit( RepositoryPolicy repositoryPolicy )
1196 {
1197 if ( repositoryPolicy != null )
1198 {
1199
1200 String orgEnabled = repositoryPolicy.getEnabled();
1201 String intEnabled = interpolate( orgEnabled );
1202 if ( orgEnabled != intEnabled )
1203 {
1204 repositoryPolicy.setEnabled( intEnabled );
1205 }
1206
1207 String orgUpdatePolicy = repositoryPolicy.getUpdatePolicy();
1208 String intUpdatePolicy = interpolate( orgUpdatePolicy );
1209 if ( orgUpdatePolicy != intUpdatePolicy )
1210 {
1211 repositoryPolicy.setUpdatePolicy( intUpdatePolicy );
1212 }
1213
1214 String orgChecksumPolicy = repositoryPolicy.getChecksumPolicy();
1215 String intChecksumPolicy = interpolate( orgChecksumPolicy );
1216 if ( orgChecksumPolicy != intChecksumPolicy )
1217 {
1218 repositoryPolicy.setChecksumPolicy( intChecksumPolicy );
1219 }
1220 }
1221 }
1222
1223 private void visit( Dependency dependency )
1224 {
1225 if ( dependency != null )
1226 {
1227 String org, val;
1228
1229 org = dependency.getGroupId();
1230 val = interpolate( org );
1231 if ( org != val )
1232 {
1233 dependency.setGroupId( val );
1234 dependency.clearManagementKey();
1235 }
1236
1237 org = dependency.getArtifactId();
1238 val = interpolate( org );
1239 if ( org != val )
1240 {
1241 dependency.setArtifactId( val );
1242 dependency.clearManagementKey();
1243 }
1244
1245 org = dependency.getVersion();
1246 val = interpolate( org );
1247 if ( org != val )
1248 {
1249 dependency.setVersion( val );
1250 }
1251
1252 org = dependency.getType();
1253 val = interpolate( org );
1254 if ( org != val )
1255 {
1256 dependency.setType( val );
1257 dependency.clearManagementKey();
1258 }
1259
1260 org = dependency.getClassifier();
1261 val = interpolate( org );
1262 if ( org != val )
1263 {
1264 dependency.setClassifier( val );
1265 dependency.clearManagementKey();
1266 }
1267
1268 org = dependency.getScope();
1269 val = interpolate( org );
1270 if ( org != val )
1271 {
1272 dependency.setScope( val );
1273 }
1274
1275 org = dependency.getSystemPath();
1276 val = interpolate( org );
1277 if ( org != val )
1278 {
1279 dependency.setSystemPath( val );
1280 }
1281
1282 for ( Exclusion exclusion : dependency.getExclusions() )
1283 {
1284 visit( exclusion );
1285 }
1286
1287 org = dependency.getOptional();
1288 val = interpolate( org );
1289 if ( org != val )
1290 {
1291 dependency.setOptional( val );
1292 }
1293 }
1294 }
1295
1296 private void visit( Exclusion exclusion )
1297 {
1298 if ( exclusion != null )
1299 {
1300 String org, val;
1301
1302 org = exclusion.getGroupId();
1303 val = interpolate( org );
1304 if ( org != val )
1305 {
1306 exclusion.setGroupId( val );
1307 }
1308
1309 org = exclusion.getArtifactId();
1310 val = interpolate( org );
1311 if ( org != val )
1312 {
1313 exclusion.setArtifactId( val );
1314 }
1315 }
1316 }
1317
1318 private void visit( Reporting reporting )
1319 {
1320 if ( reporting != null )
1321 {
1322 String org, val;
1323
1324 org = reporting.getExcludeDefaults();
1325 val = interpolate( org );
1326 if ( org != val )
1327 {
1328 reporting.setExcludeDefaults( val );
1329 }
1330
1331 org = reporting.getOutputDirectory();
1332 val = interpolate( org );
1333 if ( org != val )
1334 {
1335 reporting.setOutputDirectory( val );
1336 }
1337
1338 for ( ReportPlugin plugin : reporting.getPlugins() )
1339 {
1340 visit( plugin );
1341 }
1342 }
1343 }
1344
1345 private void visit( ReportPlugin plugin )
1346 {
1347 if ( plugin != null )
1348 {
1349 String org, val;
1350
1351 org = plugin.getInherited();
1352 val = interpolate( org );
1353 if ( org != val )
1354 {
1355 plugin.setInherited( val );
1356 }
1357
1358 visit( (Xpp3Dom) plugin.getConfiguration() );
1359
1360 org = plugin.getGroupId();
1361 val = interpolate( org );
1362 if ( org != val )
1363 {
1364 plugin.setGroupId( val );
1365 }
1366
1367 org = plugin.getArtifactId();
1368 val = interpolate( org );
1369 if ( org != val )
1370 {
1371 plugin.setArtifactId( val );
1372 }
1373
1374 org = plugin.getVersion();
1375 val = interpolate( org );
1376 if ( org != val )
1377 {
1378 plugin.setVersion( val );
1379 }
1380
1381 for ( ReportSet reportSet : plugin.getReportSets() )
1382 {
1383 visit( reportSet );
1384 }
1385 }
1386 }
1387
1388 private void visit( ReportSet reportSet )
1389 {
1390 if ( reportSet != null )
1391 {
1392 String org, val;
1393
1394 org = reportSet.getInherited();
1395 val = interpolate( org );
1396 if ( org != val )
1397 {
1398 reportSet.setInherited( val );
1399 }
1400
1401 visit( (Xpp3Dom) reportSet.getConfiguration() );
1402
1403 org = reportSet.getId();
1404 val = interpolate( org );
1405 if ( org != val )
1406 {
1407 reportSet.setId( val );
1408 }
1409
1410 visit( reportSet.getReports() );
1411 }
1412 }
1413
1414 private void visit( Properties properties )
1415 {
1416 if ( properties != null )
1417 {
1418 for ( Map.Entry<Object, Object> entry : properties.entrySet() )
1419 {
1420 Object v = entry.getValue();
1421 if ( v instanceof String )
1422 {
1423 String value = (String) v;
1424 String inter = interpolate( value );
1425 if ( value != inter )
1426 {
1427 entry.setValue( inter );
1428 }
1429 }
1430 }
1431 }
1432 }
1433
1434 private void visit( List<String> list )
1435 {
1436 if ( list != null )
1437 {
1438 ListIterator<String> it = list.listIterator();
1439 while ( it.hasNext() )
1440 {
1441 String value = it.next();
1442 String inter = interpolate( value );
1443 if ( value != inter )
1444 {
1445 it.set( inter );
1446 }
1447 }
1448 }
1449 }
1450
1451 private String interpolate( String value )
1452 {
1453 return interpolator.interpolate( value );
1454 }
1455
1456 }
1457 }