gnodet-bot commented on code in PR #13392:
URL: https://github.com/apache/maven/pull/13392#discussion_r4231369873


##########
impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java:
##########
@@ -162,20 +165,43 @@ public void execute(final MavenSession session, final 
List<MojoExecution> mojoEx
 
         final PhaseRecorder phaseRecorder = new 
PhaseRecorder(session.getCurrentProject());
 
+        // Resolve the mojo execution filter once per project execution.
+        final List<FilterPredicate> filterPredicates = 
resolveFilterPredicates(session);
+
         mojosExecutionStrategy.get().execute(mojoExecutions, session, new 
MojoExecutionRunner() {
             @Override
             public void run(MojoExecution mojoExecution) throws 
LifecycleExecutionException {
-                MojoExecutor.this.execute(session, mojoExecution, 
dependencyContext, phaseRecorder);
+                MojoExecutor.this.execute(session, mojoExecution, 
dependencyContext, phaseRecorder, filterPredicates);
             }
         });
     }
 
+    /**
+     * Resolves the mojo execution filter predicates for this build.
+     * Uses {@code -Dmaven.lifecycle.filter} user property; returns an empty 
list if absent.
+     */
+    private List<FilterPredicate> resolveFilterPredicates(MavenSession 
session) throws LifecycleExecutionException {
+        Properties userProps = session.getUserProperties();
+        String filterExpression = userProps != null ? 
userProps.getProperty(MojoExecutionFilter.PROPERTY_NAME) : null;
+        try {
+            return MojoExecutionFilter.parse(filterExpression);
+        } catch (IllegalArgumentException e) {
+            throw new LifecycleExecutionException(
+                    "Invalid value for '" + MojoExecutionFilter.PROPERTY_NAME 
+ "': " + e.getMessage(), e);
+        }
+    }
+
     private void execute(
             MavenSession session,
             MojoExecution mojoExecution,
             DependencyContext dependencyContext,
-            PhaseRecorder phaseRecorder)
+            PhaseRecorder phaseRecorder,
+            List<FilterPredicate> filterPredicates)
             throws LifecycleExecutionException {
+        if (MojoExecutionFilter.matches(mojoExecution, filterPredicates)) {
+            LOGGER.debug("Skipping {} (filtered by {})", 
mojoExecution.getGoal(), MojoExecutionFilter.PROPERTY_NAME);

Review Comment:
   💡 **Suggestion:** Consider upgrading this log from `DEBUG` to `INFO` — when 
a user sets `-Dmaven.lifecycle.filter`, they likely want confirmation that 
their filter is active and which goals are being skipped. A `DEBUG`-level 
message is invisible by default and hard to discover.
   
   ```suggestion
               LOGGER.info("Skipping {} (filtered by {})", 
mojoExecution.getGoal(), MojoExecutionFilter.PROPERTY_NAME);
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to