This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 1376aa9ea4e199eaee54f79b55ca01992c4ba1ef
Author: Guillaume Nodet <[email protected]>
AuthorDate: Wed Oct 8 06:53:12 2025 +0000

    Use Maven API constants for phase names instead of hardcoded strings
    
    Replace hardcoded phase name strings with proper Maven API constants:
    - Use Lifecycle.BEFORE and Lifecycle.AFTER for phase prefixes
    - Use Lifecycle.Phase.CLEAN and Lifecycle.Phase.INTEGRATION_TEST for phase 
names
    - Use Lifecycle.SITE for site lifecycle phase
    
    This ensures consistency with Maven's lifecycle definitions and makes
    the code more maintainable by using the official API constants.
---
 .../cling/invoker/mvnup/goals/ModelUpgradeStrategy.java    | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git 
a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/ModelUpgradeStrategy.java
 
b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/ModelUpgradeStrategy.java
index d6e3d8f331..6a6d18bbe0 100644
--- 
a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/ModelUpgradeStrategy.java
+++ 
b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/ModelUpgradeStrategy.java
@@ -25,6 +25,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.maven.api.Lifecycle;
 import org.apache.maven.api.cli.mvnup.UpgradeOptions;
 import org.apache.maven.api.di.Named;
 import org.apache.maven.api.di.Priority;
@@ -299,21 +300,22 @@ private void upgradeDeprecatedPhases(Document 
pomDocument, UpgradeContext contex
 
     /**
      * Creates the mapping of deprecated phase names to their Maven 4 
equivalents.
+     * Uses Maven API constants to ensure consistency with the lifecycle 
definitions.
      */
     private Map<String, String> createPhaseUpgradeMap() {
         Map<String, String> phaseUpgrades = new HashMap<>();
 
         // Clean lifecycle aliases
-        phaseUpgrades.put("pre-clean", "before:clean");
-        phaseUpgrades.put("post-clean", "after:clean");
+        phaseUpgrades.put("pre-clean", Lifecycle.BEFORE + 
Lifecycle.Phase.CLEAN);
+        phaseUpgrades.put("post-clean", Lifecycle.AFTER + 
Lifecycle.Phase.CLEAN);
 
         // Default lifecycle aliases
-        phaseUpgrades.put("pre-integration-test", "before:integration-test");
-        phaseUpgrades.put("post-integration-test", "after:integration-test");
+        phaseUpgrades.put("pre-integration-test", Lifecycle.BEFORE + 
Lifecycle.Phase.INTEGRATION_TEST);
+        phaseUpgrades.put("post-integration-test", Lifecycle.AFTER + 
Lifecycle.Phase.INTEGRATION_TEST);
 
         // Site lifecycle aliases
-        phaseUpgrades.put("pre-site", "before:site");
-        phaseUpgrades.put("post-site", "after:site");
+        phaseUpgrades.put("pre-site", Lifecycle.BEFORE + Lifecycle.SITE);
+        phaseUpgrades.put("post-site", Lifecycle.AFTER + Lifecycle.SITE);
 
         return phaseUpgrades;
     }

Reply via email to