Class ModuleNameFixStrategy

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

@Named @Singleton @Priority(12) public class ModuleNameFixStrategy extends AbstractUpgradeStrategy
Strategy for fixing invalid Automatic-Module-Name manifest entries in POM files.

Java module names (as validated by SourceVersion.isName(CharSequence)) must be dot-separated sequences of valid Java identifiers. Dashes (-) are the most common illegal character because Maven artifact IDs conventionally use them, and projects often copy the artifact ID into the Automatic-Module-Name manifest entry without sanitizing it.

Since maven-archiver 3.3.0 (MSHARED-773), the archiver validates Automatic-Module-Name entries and fails the build on invalid names. When mvnup upgrades maven-jar-plugin (or other packaging plugins) to versions that pull in the newer archiver, previously-unchecked invalid names surface as build failures.

This strategy scans all packaging plugin configurations for <archive><manifestEntries><Automatic-Module-Name> elements whose values contain dashes, and replaces the dashes with dots to produce a valid module name.

See Also:
  • Constructor Details

    • ModuleNameFixStrategy

      public ModuleNameFixStrategy()
  • 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