gnodet-bot commented on code in PR #13546:
URL: https://github.com/apache/maven/pull/13546#discussion_r4283313641
##########
api/maven-api-core/src/main/java/org/apache/maven/api/Constants.java:
##########
@@ -880,5 +880,18 @@ public final class Constants {
@Config(type = "java.lang.Boolean", defaultValue = "false", source =
Config.Source.SYSTEM_PROPERTIES)
public static final String MAVEN_TEMPFILE_KEEP = "maven.tempfile.keep";
+ /**
+ * 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
Review Comment:
⚠️ **Wrong `@since` tag** — this constant is new in 4.1.0, not 4.0.0.
`MAVEN_TEMPFILE_KEEP` immediately above and all other recently added constants
use `@since 4.1.0`.
```suggestion
* @since 4.1.0
```
##########
impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java:
##########
@@ -135,7 +136,11 @@ public Iterator<Lifecycle> iterator() {
@Override
public Stream<Lifecycle> stream() {
- return
providers.stream().map(ExtensibleEnumProvider::provides).flatMap(Collection::stream);
+ return providers.stream()
+ .map(ExtensibleEnumProvider::provides)
+ .flatMap(Collection::stream)
+ .filter(lf ->
!Boolean.getBoolean(Constants.MAVEN_SITE_LIFECYCLE_DISABLED)
+ || !Lifecycle.SITE.equals(lf.id()));
Review Comment:
💡 **Cache the system property as a `static final` field** —
`Boolean.getBoolean()` is called per stream element on every `stream()`
invocation. Maven 3.10.x's `DefaultLifecycles.java` uses:
```java
private static final boolean SITE_LIFECYCLE_DISABLED =
Boolean.getBoolean(Constants.MAVEN_SITE_LIFECYCLE_DISABLED);
```
Then simplify the filter to:
```suggestion
.filter(lf -> !SITE_LIFECYCLE_DISABLED ||
!Lifecycle.SITE.equals(lf.id()));
```
--
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]