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


##########
impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java:
##########
@@ -89,6 +90,8 @@ public class DefaultLifecycleRegistry implements 
LifecycleRegistry {
 
     private static final String MAVEN_PLUGINS = "org.apache.maven.plugins:";
 
+    private static final boolean SITE_DISABLED = 
Boolean.getBoolean(Constants.MAVEN_SITE_LIFECYCLE_DISABLED);

Review Comment:
   💡 `SITE_DISABLED` is a `static final` boolean read at class-load time via 
`Boolean.getBoolean()`. The system property cannot be toggled after JVM 
startup, so testing the `true` path requires a forked JVM or an IT launched 
with `-Dmaven.site.lifecycle.disabled=true`. The added test only validates the 
`false` path — consider adding an integration test that asserts the site 
lifecycle is absent when the property is set.



##########
impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java:
##########
@@ -154,9 +157,12 @@ public Stream<Lifecycle> stream() {
             lookup.lookupList(LifecycleProvider.class).stream()
                     .flatMap(p -> p.provides().stream())
                     .forEach(lf -> result.put(lf.id(), lf));
-            return result.values().stream();
+            return result.values().stream().filter(lf -> !SITE_DISABLED || 
!Lifecycle.SITE.equals(lf.id()));
         }
-        return 
providers.stream().map(ExtensibleEnumProvider::provides).flatMap(Collection::stream);
+        return providers.stream()
+                .map(ExtensibleEnumProvider::provides)
+                .flatMap(Collection::stream)
+                .filter(lf -> !SITE_DISABLED || 
!Lifecycle.SITE.equals(lf.id()));

Review Comment:
   💡 The predicate `lf -> !SITE_DISABLED || !Lifecycle.SITE.equals(lf.id())` is 
duplicated here and on line 160. Extract it as a named constant or local 
variable to remove the repetition:
   
   ```suggestion
                   .filter(lf -> !SITE_DISABLED || 
!Lifecycle.SITE.equals(lf.id()));
   ```
   
   _(No code change above — the suggestion is to extract both occurrences into 
a named `Predicate<Lifecycle>` field to avoid the duplication.)_



-- 
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