Interface ModelTransformer
- All Superinterfaces:
SpiService
Interface for model transformers that can modify Maven project models at different stages of processing.
Model transformers allow plugins and extensions to modify the POM model during the build process. Transformations can be applied at three different stages:
- File model - The raw model as read directly from the file
- Raw model - The model after inheritance has been applied
- Effective model - The fully processed model with all interpolation and inheritance applied
Implementations of this interface will be discovered through the Java ServiceLoader mechanism and will be called in sequence during model building.
Example usage:
public class CustomModelTransformer implements ModelTransformer { public Model transformEffectiveModel(Model model) throws ModelTransformerException { // Add a custom property to all models model.getProperties().put("custom.timestamp", System.currentTimeMillis()); return model; } }
- Since:
- 4.0.0
-
Method Summary
Modifier and TypeMethodDescriptiondefault Model
transformEffectiveModel
(Model model) Apply a transformation on the effective models.default Model
transformFileModel
(Model model) Apply a transformation on the file model.default Model
transformRawModel
(Model model) Apply a transformation on the raw models.
-
Method Details
-
transformFileModel
Apply a transformation on the file model. This method will be called on each file model being loaded, just before validation.- Parameters:
model
- the input model- Returns:
- the transformed model, or the input model if no transformation is needed
- Throws:
ModelTransformerException
-
transformRawModel
Apply a transformation on the raw models. This method will be called on each raw model being loaded, just before validation.- Parameters:
model
- the input model- Returns:
- the transformed model, or the input model if no transformation is needed
- Throws:
ModelTransformerException
-
transformEffectiveModel
@Nonnull default Model transformEffectiveModel(@Nonnull Model model) throws ModelTransformerException Apply a transformation on the effective models. This method will be called on each effective model being loaded, just before validation.- Parameters:
model
- the input model- Returns:
- the transformed model, or the input model if no transformation is needed
- Throws:
ModelTransformerException
-