Class ConditionProfileActivator
java.lang.Object
org.apache.maven.internal.impl.model.profile.ConditionProfileActivator
- All Implemented Interfaces:
ProfileActivator
@Named("condition")
@Singleton
public class ConditionProfileActivator
extends Object
implements ProfileActivator
This class is responsible for activating profiles based on conditions specified in the profile's activation section.
It evaluates the condition expression and determines whether the profile should be active.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConditionProfileActivator
(VersionParser versionParser) Constructs a new ConditionProfileActivator with the necessary dependencies. -
Method Summary
Modifier and TypeMethodDescription(package private) static String
doGetProperty
(ProfileActivationContext context, String name) boolean
isActive
(Profile profile, ProfileActivationContext context, ModelProblemCollector problems) Determines whether a profile should be active based on its condition.boolean
presentInConfig
(Profile profile, ProfileActivationContext context, ModelProblemCollector problems) Checks if the condition is present in the profile's configuration.(package private) static String
property
(ProfileActivationContext context, String name) Retrieves the value of a property from the project context.registerFunctions
(ProfileActivationContext context, VersionParser versionParser) Registers the condition functions that can be used in profile activation expressions.
-
Field Details
-
versionParser
-
-
Constructor Details
-
ConditionProfileActivator
Constructs a new ConditionProfileActivator with the necessary dependencies.- Parameters:
versionParser
- The parser for handling version comparisons
-
-
Method Details
-
isActive
public boolean isActive(Profile profile, ProfileActivationContext context, ModelProblemCollector problems) Determines whether a profile should be active based on its condition.- Specified by:
isActive
in interfaceProfileActivator
- Parameters:
profile
- The profile to evaluatecontext
- The context in which the profile is being evaluatedproblems
- A collector for any problems encountered during evaluation- Returns:
- true if the profile should be active, false otherwise
-
presentInConfig
public boolean presentInConfig(Profile profile, ProfileActivationContext context, ModelProblemCollector problems) Checks if the condition is present in the profile's configuration.- Specified by:
presentInConfig
in interfaceProfileActivator
- Parameters:
profile
- The profile to checkcontext
- The context in which the profile is being evaluatedproblems
- A collector for any problems encountered during evaluation- Returns:
- true if the condition is present and not blank, false otherwise
-
registerFunctions
public static Map<String,ConditionParser.ExpressionFunction> registerFunctions(ProfileActivationContext context, VersionParser versionParser) Registers the condition functions that can be used in profile activation expressions.- Parameters:
context
- The profile activation contextversionParser
- The parser for handling version comparisons- Returns:
- A map of function names to their implementations
-
property
Retrieves the value of a property from the project context. Special function used to support the${property}
syntax. The profile activation is done twice: once on the file model (so the model which has just been read from the file) and once while computing the effective model (so the model which will be used to build the project). We do need those two activations to be consistent, so we need to restrict access to properties that cannot change between file and effective model.- Parameters:
name
- The property name- Returns:
- The value of the property, or null if not found
- Throws:
IllegalArgumentException
- if the number of arguments is not exactly one
-
doGetProperty
-