feat/v2-deprecations: Warn on legacy config knobs and flip docs to v2#22
Merged
vedanthvdev merged 1 commit intomasterfrom Apr 22, 2026
Merged
feat/v2-deprecations: Warn on legacy config knobs and flip docs to v2#22vedanthvdev merged 1 commit intomasterfrom
vedanthvdev merged 1 commit intomasterfrom
Conversation
Phase 2 of the v2 rollout per docs/DESIGN-v2.md §4: surface deprecation warnings for the three legacy config knobs (runAllIfNoMatches, runAllOnNonJavaChange, excludePaths) without breaking any existing build, and flip every documentation example to the v2 vocabulary so new users only see the supported API. AffectedTestsConfig now exposes a deprecationWarnings() list populated at build time by detecting which nullable builder fields the caller explicitly touched. Zero-config installs produce zero warnings even though the effective config still resolves via the legacy-boolean shim — the list tracks caller intent, not the engine's resolution path, so builds that never typed the old names stay silent. The AffectedTestTask emits each warning through getLogger().warn() right before the summary line so the message sits adjacent to the config it describes. Each warning names the deprecated knob, the removal version (v2.0.0), and the v2 replacement (onEmptyDiff/onDiscoveryEmpty, onUnmappedFile, or ignorePaths) so operators can fix their build.gradle from the log alone. The README gains a full "Migrating from v1 config" section with a deprecation timeline, before/after table, worked example (single mode="ci" line replaces two legacy booleans in the common case), and a decision tree for each legacy knob. The main configuration example drops the "Legacy booleans (still supported)" block so new users only see v2 vocabulary, and the AffectedTestsExtension javadoc sample flips to mode + onXxx + ignorePaths + outOfScopeTestDirs. The behaviour reference table also updates its "override knob" column to name v2 knobs instead of the legacy flags. Seven new tests in AffectedTestsConfigTest lock down the contract: zero warnings for zero-config builds, one warning per legacy knob (each containing the knob name and the v2 replacement), stable ordering when multiple legacy knobs are set, and an immutability guard so the task cannot accidentally leak mutations to the list.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 2 of the v2 rollout per
docs/DESIGN-v2.md§4 — signal that v1 config is on its way out without breaking any existing build.Three things:
runAllIfNoMatches,runAllOnNonJavaChange, orexcludePaths. Zero-config installs stay silent.AffectedTestsExtensionjavadoc. Behaviour-reference table drops the legacy-flag mentions from its "override knob" column.What the warnings look like
Emitted via `Logger.warn(...)` on every `affectedTest` run, immediately before the summary line so the warning sits adjacent to the config it describes. Gradle's deprecation dashboard and build-scan `warnings` stream pick this up as a first-class warning (not an info line).
Why the detection is on *caller intent*, not resolution path
The config builder uses `Boolean` / `List` nullable backing fields for the legacy setters. `deprecationWarnings()` is populated by inspecting those nullables directly — `null` means "caller never typed it", non-null means "caller typed it".
This matters: zero-config installs still internally route through the legacy-boolean shim (because the effective `onEmptyDiff` default etc. is derived from the `runAllIfNoMatches=false` hardcoded fallback). If the detection were based on the shim walking that path, we'd spam a warning on every zero-config build and train users to ignore deprecations before the real ones land. Instead, only callers who actually typed the old name in their `build.gradle` see anything.
Migration guide highlights
The new README section boils down to one insight: for 95% of legacy configs, a single `mode = "ci"` line replaces both booleans. The decision tree covers the remaining 5% (specifically: `runAllIfNoMatches=false` → just delete it; `runAllOnNonJavaChange=false` → `onUnmappedFile = "selected"`).
Before:
```groovy
affectedTests {
runAllIfNoMatches = true
runAllOnNonJavaChange = true
excludePaths = ["/generated/"]
transitiveDepth = 4
}
```
After:
```groovy
affectedTests {
mode = "ci"
}
```
(v2's `ignorePaths` default already covers `/generated/`, and `transitiveDepth = 4` is the new default.)
Tests
Deprecation timeline
Test plan