Class EnforcerVersionRangeStrategy

java.lang.Object
org.apache.maven.cling.invoker.mvnup.goals.AbstractUpgradeStrategy
org.apache.maven.cling.invoker.mvnup.goals.EnforcerVersionRangeStrategy
All Implemented Interfaces:
UpgradeStrategy

@Named @Singleton @Priority(18) public class EnforcerVersionRangeStrategy extends AbstractUpgradeStrategy
Strategy for widening requireMavenVersion ranges in the maven-enforcer-plugin to allow Maven 4.

Many projects use the maven-enforcer-plugin with a requireMavenVersion rule that has an exclusive upper bound at version 4 (e.g., [3.8.8,4), [3,4)), which blocks Maven 4 builds. This strategy widens such ranges to allow Maven 4 by changing the upper bound to 5 (e.g., [3.8.8,4) becomes [3.8.8,5)).

The strategy handles:

  • <configuration><rules><requireMavenVersion> in plugin declarations
  • <executions><execution><configuration><rules><requireMavenVersion> in executions
  • Both build/plugins and build/pluginManagement/plugins sections
  • Profile-scoped enforcer plugin declarations
  • Constructor Details

    • EnforcerVersionRangeStrategy

      public EnforcerVersionRangeStrategy()
  • Method Details

    • isApplicable

      public boolean isApplicable(UpgradeContext context)
      Description copied from interface: UpgradeStrategy
      Checks if this strategy is applicable given the current options.
      Parameters:
      context - the upgrade context
      Returns:
      true if this strategy should be applied
    • getDescription

      public String getDescription()
      Description copied from interface: UpgradeStrategy
      Gets a description of what this strategy does.
      Returns:
      a human-readable description of the strategy
    • doApply

      protected UpgradeResult doApply(UpgradeContext context, Map<Path, eu.maveniverse.domtrip.Document> pomMap)
      Description copied from class: AbstractUpgradeStrategy
      Subclasses implement the actual upgrade logic here.
      Specified by:
      doApply in class AbstractUpgradeStrategy
      Parameters:
      context - the upgrade context
      pomMap - map of all POM files in the project
      Returns:
      the result of the upgrade operation