You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "utafrali (via GitHub)" <gi...@apache.org> on 2026/04/10 14:50:51 UTC

[PR] Warn when profile ID matches a lifecycle phase name [maven]

utafrali opened a new pull request, #11926:
URL: https://github.com/apache/maven/pull/11926

   When a profile ID matches a default Maven lifecycle phase name (e.g. "test", "deploy", "integration-test"), users can accidentally trigger that phase. This adds a validation warning to alert about the potential confusion.
   
   Includes a new test case with a POM containing both phase-matching and safe profile IDs.
   
   Closes #10310


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Warn when profile ID matches a lifecycle phase name [maven]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #11926:
URL: https://github.com/apache/maven/pull/11926#discussion_r3284330119


##########
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelValidator.java:
##########
@@ -99,6 +99,34 @@ public class DefaultModelValidator implements ModelValidator {
 
     private static final String EMPTY = "";
 
+    private static final Set<String> LIFECYCLE_PHASES = Set.of(
+            "clean",
+            "validate",
+            "initialize",
+            "generate-sources",
+            "process-sources",
+            "generate-resources",
+            "process-resources",
+            "compile",
+            "process-classes",
+            "generate-test-sources",
+            "process-test-sources",
+            "generate-test-resources",
+            "process-test-resources",
+            "test-compile",
+            "process-test-classes",
+            "test",
+            "prepare-package",
+            "package",
+            "pre-integration-test",
+            "integration-test",
+            "post-integration-test",
+            "verify",
+            "install",
+            "deploy",
+            "site",

Review Comment:
   This hardcoded set duplicates phase names that are already defined as constants in `org.apache.maven.api.Lifecycle.Phase` (in `maven-api-core`, which is a dependency of this module). It also mixes Maven 3 legacy phase names (e.g. `generate-sources`, `process-sources`, `process-classes`, `prepare-package`, `pre-integration-test`, `post-integration-test`, `site-deploy`) with the standard ones, while missing Maven 4 phases like `all`, `each`, `build`, `sources`, `resources`, `ready`, and `unit-test`.
   
   Please build this set from the existing `Lifecycle.Phase` constants instead of duplicating strings. For example:
   
   ```suggestion
       private static final Set<String> LIFECYCLE_PHASES = Set.of(
               Lifecycle.Phase.ALL,
               Lifecycle.Phase.EACH,
               Lifecycle.Phase.BUILD,
               Lifecycle.Phase.INITIALIZE,
               Lifecycle.Phase.VALIDATE,
               Lifecycle.Phase.SOURCES,
               Lifecycle.Phase.RESOURCES,
               Lifecycle.Phase.COMPILE,
               Lifecycle.Phase.READY,
               Lifecycle.Phase.PACKAGE,
               Lifecycle.Phase.VERIFY,
               Lifecycle.Phase.UNIT_TEST,
               Lifecycle.Phase.TEST_SOURCES,
               Lifecycle.Phase.TEST_RESOURCES,
               Lifecycle.Phase.TEST_COMPILE,
               Lifecycle.Phase.TEST,
               Lifecycle.Phase.INTEGRATION_TEST,
               Lifecycle.Phase.INSTALL,
               Lifecycle.Phase.DEPLOY,
               Lifecycle.Phase.CLEAN,
               Lifecycle.SITE);
   ```
   
   You may also want to include the legacy Maven 3 aliases (via `Lifecycle.aliases()`) if the goal is to catch those as well, but at minimum the canonical names should come from the constants.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Warn when profile ID matches a lifecycle phase name [maven]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet closed pull request #11926: Warn when profile ID matches a lifecycle phase name
URL: https://github.com/apache/maven/pull/11926


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org