You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "gnodet (via GitHub)" <gi...@apache.org> on 2026/10/15 12:53:52 UTC
[PR] [4.0.x] Fix #11759: add maven.site.lifecycle.disabled system property to opt out of the site lifecycle [maven]
gnodet opened a new pull request, #13547:
URL: https://github.com/apache/maven/pull/13547
Port of #11970 (merged on `maven-3.10.x`) to `maven-4.0.x`.
## Summary
When `-Dmaven.site.lifecycle.disabled=true` is set, the `site` lifecycle is excluded
from the `DefaultLifecycleRegistry` stream. Maven will not resolve or bind the
`maven-site-plugin` unless it is explicitly configured in the POM.
This is a JVM system property only (read via `Boolean.getBoolean()`); it is not resolved
through Maven's property mechanism (pom.xml, profiles, settings.xml).
## Changes
- `Constants.MAVEN_SITE_LIFECYCLE_DISABLED` constant added with `@Config` annotation
- Filter added in `DefaultLifecycleRegistry.stream()` — the natural aggregation point for
all lifecycle consumers on Maven 4.x
Full backward compatibility is preserved: the property defaults to `false`.
Fixes #11759
--
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] [4.0.x] Fix #11759: add maven.site.lifecycle.disabled system property to opt out of the site lifecycle [maven]
Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #13547:
URL: https://github.com/apache/maven/pull/13547#discussion_r4293539759
##########
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
+ */
Review Comment:
⚠️ **Missing `readOnly = true`**: All 7 existing `SYSTEM_PROPERTIES`-sourced `@Config` annotations in this file include `readOnly = true` — this one doesn't. JVM system properties are set at startup and are effectively read-only from Maven's perspective. Add `readOnly = true` for consistency:
```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 +156,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();
+ stream = result.values().stream();
+ } else {
+ stream = providers.stream().map(ExtensibleEnumProvider::provides).flatMap(Collection::stream);
}
- return providers.stream().map(ExtensibleEnumProvider::provides).flatMap(Collection::stream);
+ return stream.filter(
+ lf -> !Boolean.getBoolean(Constants.MAVEN_SITE_LIFECYCLE_DISABLED) || !Lifecycle.SITE.equals(lf.id()));
Review Comment:
⚠️ **`Boolean.getBoolean()` re-evaluated on every call**: `stream()` is called per-project during the build. The [3.10.x backport (PR #11970)](https://github.com/apache/maven/pull/11970) correctly caches this in a `private static final boolean` field. Cache it here too:
```suggestion
lf -> !SITE_DISABLED || !Lifecycle.SITE.equals(lf.id()));
```
And add near the top of the class:
```java
private static final boolean SITE_DISABLED = Boolean.getBoolean(Constants.MAVEN_SITE_LIFECYCLE_DISABLED);
```
--
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] [4.0.x] Fix #11759: add maven.site.lifecycle.disabled system property to opt out of the site lifecycle [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet merged PR #13547:
URL: https://github.com/apache/maven/pull/13547
--
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] [4.0.x] Fix #11759: add maven.site.lifecycle.disabled system property to opt out of the site lifecycle [maven]
Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [4.0.x] Fix #11759: add maven.site.lifecycle.disabled system property to opt out of the site lifecycle [maven]
Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [4.0.x] Fix #11759: add maven.site.lifecycle.disabled system property to opt out of the site lifecycle [maven]
Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #13547:
URL: https://github.com/apache/maven/pull/13547#discussion_r4298027009
##########
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:
💡 **Nit:** Same filter predicate as line 160 — consider extracting to a `Predicate<Lifecycle>` constant to avoid duplication:
```suggestion
.filter(lf -> !SITE_DISABLED || !Lifecycle.SITE.equals(lf.id()));
```
Or extract it:
```java
private static final Predicate<Lifecycle> SITE_FILTER =
lf -> !SITE_DISABLED || !Lifecycle.SITE.equals(lf.id());
```
Not a blocker.
--
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