gnodet commented on issue #13230: URL: https://github.com/apache/maven/issues/13230#issuecomment-5766901229
## Follow-up: `--skip-phases` for 4.1.0 The second part of this fix (targeted at 4.1.0 / master) is the introduction of a proper `--skip-phases` CLI option as a plugin-agnostic replacement for ad-hoc conventions like `-DskipTests`. ### Motivation / Use Cases The current `-DskipTests` convention has several problems: - Not universal: it works for Surefire but not for all plugins (e.g. does not skip integration tests run by Failsafe) - Not composable: skipping both unit tests and integration tests requires `-DskipTests -DskipITs` or `-Dmaven.test.skip=true`, with inconsistent semantics across plugins - Convention-based: each plugin must opt in; there is no first-class Maven mechanism Real-world scenarios where skipping test phases is legitimate: 1. **Large projects with long test suites** (Camel, Quarkus): a full build can take hours. These projects rely on green CI (which tests multiple JDK/platform combinations) rather than local test runs. Running tests locally only validates one specific environment anyway. 2. **Release builds**: for projects with flaky tests or slow test suites, the release is cut from a commit that already passed CI. Re-running tests locally during the release process adds time and exposure to environmental issues without adding meaningful safety. 3. **Consuming a dependency snapshot**: when you want to test a third-party SNAPSHOT in your own project, you care about the generated artifact — not about running that dependency's own test suite. You want to `mvn install --skip-phases=test,integration-test` the dependency, then run your own project's tests against the freshly installed artifact. ### Design **Syntax:** ``` mvn verify --skip-phases=test,integration-test ``` Comma-separated list of phase names to skip. Option name: `--skip-phases` (long only, no short alias). **Semantics:** Phase skipping is **mojo-level inhibition**, not graph surgery. The skipped phases remain in the DAG — their predecessors and successors are unaffected. Only the mojo executions bound to a skipped phase are suppressed. This mirrors what `-DskipTests` does for Surefire, but as a first-class CLI feature that works uniformly across all plugins. Example: `--skip-phases=test,integration-test` on `mvn verify` runs compile, resources, test-compile, test-resources, package, and verify — but skips all mojos bound to `test` and `integration-test`. **Implementation touch points:** 1. `MavenOptions` (API) — add `Optional<List<String>> skippedPhases()` 2. `CommonsCliMavenOptions` + `CLIManager` — register the option, parse comma-separated values 3. `LayeredMavenOptions` — merge via `collectListIfPresentOrEmpty` 4. `MavenExecutionRequest` — add `getSkippedPhases()` / `setSkippedPhases()` 5. `MavenInvoker.populateRequest()` — wire option → request 6. `BuildPlanExecutor.plan()` — when attaching mojos to a `BuildStep`, skip if `resolvedPhase` is in the skipped set 7. The sequential builder path (single-threaded / multi-threaded) needs the same guard The skipped-phase set should be propagated via `MavenSession` so that both the concurrent and sequential builder paths can access it uniformly without duplicating the check. -- 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]
