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