Resolve POM Maven "properties" in attribute values and inherit from parent. Update the POM attributes in place. Use the extra keywords to override and supplement existing properties.
(self, **extra_properties)
| 556 | return MavenPom._replace_props(text, properties) |
| 557 | |
| 558 | def resolve(self, **extra_properties): |
| 559 | """ |
| 560 | Resolve POM Maven "properties" in attribute values and inherit |
| 561 | from parent. Update the POM attributes in place. Use the extra |
| 562 | keywords to override and supplement existing properties. |
| 563 | """ |
| 564 | # inherit first to get essential parent properties |
| 565 | # FIXME: the parent needs to be resolved first!? but we have a chicken and egg problem then |
| 566 | if self.parent: |
| 567 | pass |
| 568 | |
| 569 | self._inherit_from_parent() |
| 570 | |
| 571 | # then collect properties + extra |
| 572 | properties = dict(self.properties) |
| 573 | properties.update(self._extra_properties()) |
| 574 | |
| 575 | # "extra" properties are things that would be loaded from a |
| 576 | # properties files and provided as is they overwrite any |
| 577 | # existing property |
| 578 | properties.update(extra_properties) |
| 579 | |
| 580 | if TRACE: |
| 581 | logger.debug('MavenPom.resolve: properties before self-resolution:\n{}'.format(pformat(properties))) |
| 582 | |
| 583 | # FIXME: we could remove any property that itself contains |
| 584 | # ${property} as we do not know how to resolve these |
| 585 | # recursively. Or we could do a single pass on properties to |
| 586 | # resolve values against themselves |
| 587 | for key, value in list(properties.items()): |
| 588 | properties[key] = MavenPom._replace_props(value, properties) |
| 589 | |
| 590 | if TRACE: |
| 591 | logger.debug('MavenPom.resolve: used properties:\n{}'.format(pformat(properties))) |
| 592 | |
| 593 | # these attributes are plain strings |
| 594 | plain_attributes = [ |
| 595 | 'group_id', |
| 596 | 'version', |
| 597 | 'classifier', |
| 598 | 'packaging', |
| 599 | 'name', |
| 600 | 'description', |
| 601 | 'inception_year', |
| 602 | 'url', |
| 603 | 'organization_name', |
| 604 | 'organization_url', |
| 605 | ] |
| 606 | for attr in plain_attributes: |
| 607 | attr_val = getattr(self, attr, None) |
| 608 | if not attr_val: |
| 609 | continue |
| 610 | resolved = self._replace_properties(attr_val, properties) |
| 611 | setattr(self, attr, resolved) |
| 612 | |
| 613 | # these attributes are mappings |
| 614 | mapping_attributes = [ |
| 615 | 'scm', |