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


##########
api/maven-api-core/src/main/java/org/apache/maven/api/Constants.java:
##########
@@ -790,5 +790,18 @@ public final class Constants {
     @Config(type = "java.lang.Boolean", defaultValue = "false")
     public static final String MAVEN_MODEL_DEPENDENCY_INTERPOLATION_FULL = 
"maven.model.dependencyInterpolation.full";
 
+    /**
+     * System property to disable the {@code site} lifecycle.
+     * When set to {@code true} via {@code 
-Dmaven.site.lifecycle.disabled=true}, the {@code site}
+     * lifecycle is excluded from the default lifecycles, so Maven will not 
resolve or bind the
+     * {@code maven-site-plugin} unless it is explicitly configured in the POM.
+     * This is a JVM system property only (read via {@link 
Boolean#getBoolean(String)});
+     * it is not resolved through Maven's property mechanism (pom.xml, 
profiles, settings.xml).
+     *
+     * @since 4.0.0
+     */
+    @Config(type = "java.lang.Boolean", defaultValue = "false", source = 
Config.Source.SYSTEM_PROPERTIES)

Review Comment:
   ⚠️ **Missing `readOnly = true` on `@Config`** (still unresolved)
   
   The `MAVEN_SITE_LIFECYCLE_DISABLED` constant has `source = 
Config.Source.SYSTEM_PROPERTIES` but is missing `readOnly = true`. Without it, 
a build file could theoretically write to this property — unintended for a JVM 
system-property-only flag. Compare with other system-property constants in this 
file that correctly use `readOnly = true`.
   
   ```suggestion
       @Config(type = "java.lang.Boolean", defaultValue = "false", source = 
Config.Source.SYSTEM_PROPERTIES, readOnly = true)
   ```



##########
impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java:
##########
@@ -154,9 +155,15 @@ 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 -> 
!Boolean.getBoolean(Constants.MAVEN_SITE_LIFECYCLE_DISABLED)
+                            || !Lifecycle.SITE.equals(lf.id()));

Review Comment:
   ⚠️ **`Boolean.getBoolean()` called inline on every stream element** (still 
unresolved)
   
   `Boolean.getBoolean(Constants.MAVEN_SITE_LIFECYCLE_DISABLED)` performs a 
system property lookup on each lifecycle entry in the stream. The same pattern 
repeats on the second return path (lines 165-166). Cache it in a local variable 
before the stream:
   
   ```java
   boolean siteLifecycleDisabled = 
Boolean.getBoolean(Constants.MAVEN_SITE_LIFECYCLE_DISABLED);
   return result.values().stream()
           .filter(lf -> !siteLifecycleDisabled || 
!Lifecycle.SITE.equals(lf.id()));
   ```
   
   Apply the same fix to the second `.filter()` call on the `providers` path.



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