Class DefaultInheritanceAssembler
- java.lang.Object
-
- org.apache.maven.model.inheritance.DefaultInheritanceAssembler
-
- All Implemented Interfaces:
InheritanceAssembler
@Named @Singleton public class DefaultInheritanceAssembler extends java.lang.Object implements InheritanceAssembler
Handles inheritance of model values.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
DefaultInheritanceAssembler.InheritanceModelMerger
InheritanceModelMerger
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
CHILD_DIRECTORY
private static java.lang.String
CHILD_DIRECTORY_PROPERTY
private DefaultInheritanceAssembler.InheritanceModelMerger
merger
-
Constructor Summary
Constructors Constructor Description DefaultInheritanceAssembler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assembleModelInheritance(Model child, Model parent, ModelBuildingRequest request, ModelProblemCollector problems)
Merges values from the specified parent model into the given child model.private java.lang.String
getChildPathAdjustment(Model child, Model parent, java.lang.String childDirectory)
Calculates the relative path from the base directory of the parent to the parent directory of the base directory of the child.
-
-
-
Field Detail
-
merger
private DefaultInheritanceAssembler.InheritanceModelMerger merger
-
CHILD_DIRECTORY
private static final java.lang.String CHILD_DIRECTORY
- See Also:
- Constant Field Values
-
CHILD_DIRECTORY_PROPERTY
private static final java.lang.String CHILD_DIRECTORY_PROPERTY
- See Also:
- Constant Field Values
-
-
Method Detail
-
assembleModelInheritance
public void assembleModelInheritance(Model child, Model parent, ModelBuildingRequest request, ModelProblemCollector problems)
Description copied from interface:InheritanceAssembler
Merges values from the specified parent model into the given child model. Implementations are expected to keep parent and child completely decoupled by injecting deep copies of objects into the child rather than the original objects from the parent.- Specified by:
assembleModelInheritance
in interfaceInheritanceAssembler
- Parameters:
child
- The child model into which to merge the values inherited from the parent, must not benull
.parent
- The (read-only) parent model from which to inherit the values, may benull
.request
- The model building request that holds further settings, must not benull
.problems
- The container used to collect problems that were encountered, must not benull
.
-
getChildPathAdjustment
private java.lang.String getChildPathAdjustment(Model child, Model parent, java.lang.String childDirectory)
Calculates the relative path from the base directory of the parent to the parent directory of the base directory of the child. The general idea is to adjust inherited URLs to match the project layout (in SCM).This calculation is only a heuristic based on our conventions. In detail, the algo relies on the following assumptions:
- The parent uses aggregation and refers to the child via the modules section
- The module path to the child is considered to point at the POM rather than its base directory if the path ends with ".xml" (ignoring case)
- The name of the child's base directory matches the artifact id of the child.
- Parameters:
child
- The child model, must not benull
.parent
- The parent model, may benull
.childDirectory
- The directory defined in child model, may benull
.- Returns:
- The path adjustment, can be empty but never
null
.
-
-