Skip to content

fix: support three-state logic for arguments#1587

Merged
algomaster99 merged 2 commits into
mainfrom
claude/kind-hopper-BW6CJ
May 26, 2026
Merged

fix: support three-state logic for arguments#1587
algomaster99 merged 2 commits into
mainfrom
claude/kind-hopper-BW6CJ

Conversation

@algomaster99
Copy link
Copy Markdown
Member

@algomaster99 algomaster99 commented May 25, 2026

Summary

Convert five boolean configuration parameters (includeMavenPlugins, allowValidationFailure, allowPomValidationFailure, allowEnvironmentalValidationFailure, includeEnvironment) from primitive boolean to nullable Boolean to enable three-state logic: explicitly set via CLI/pom.xml, or null when not set. This allows proper distinction between "not configured" and "configured to false", enabling better merging of CLI arguments with stored lockfile configs.

Key Changes

  • Parameter type conversion: Changed all five boolean parameters from boolean to Boolean in AbstractLockfileMojo, removing defaultValue attributes from @Parameter annotations to allow null values.

  • Updated getConfig() logic: Modified to use null-safe comparisons (Boolean.FALSE.equals(), Boolean.TRUE.equals()) with explicit comments documenting default behavior:

    • includeMavenPlugins defaults to true when not explicitly set
    • includeEnvironment defaults to true when not explicitly set
    • Validation failure flags default to false (Error mode) when not explicitly set
  • Enhanced mergeConfigWithCliArgs() semantics: Changed from "only override if true" to "only override if non-null", preserving stored lockfile config values when CLI arguments are not explicitly provided. This prevents silent tightening of existing lockfile configs by plugin defaults.

  • Test update: Updated ValidateMojoTest.storedConfigUsedWhenCliArgNotSet() to assert isNull() instead of isFalse(), reflecting the new nullable parameter semantics.

Implementation Details

The change enables proper CLI override behavior: when a user does not specify a parameter, the stored lockfile configuration is preserved; when explicitly set (even to false), the CLI value takes precedence. This is critical for the mergeConfigWithCliArgs() method used during validation to avoid inadvertently changing validation policies from a stored lockfile.

Note: The Config() no-arg constructor default for includeMavenPlugins remains false — the default-to-true change is scoped to PR #1576 (feat: include Maven plugins by default).

claude and others added 2 commits May 25, 2026 21:12
…verridden by defaults

Boolean parameters in AbstractLockfileMojo were declared as primitive
`boolean` with a `defaultValue`, meaning Maven always bound a value
(true or false) even when the user never set the parameter. This made
it impossible for mergeConfigWithCliArgs to distinguish "explicitly
set by user" from "just the default" — the default would silently
override the stored lockfile config.

Fix: change the five bool parameters used by mergeConfigWithCliArgs
(includeMavenPlugins, allowValidationFailure, allowPomValidationFailure,
allowEnvironmentalValidationFailure, includeEnvironment) from `boolean`
to `Boolean` and remove their `defaultValue`. When null (not set),
mergeConfigWithCliArgs now preserves the lockfile's stored value;
when non-null (explicitly set via CLI or pom.xml), it overrides.

getConfig() applies system defaults for the null case:
  includeMavenPlugins → true (plugins included by default)
  includeEnvironment  → true

Also updates Config's default no-arg constructor to reflect the new
includeMavenPlugins default of true.

https://claude.ai/code/session_01PeZS3ZNzvZQDFPUXAer6ur
The default change belongs in PR #1576 (feat: include Maven plugins by default).
This PR's scope is the nullable Boolean refactor for mergeConfigWithCliArgs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@algomaster99 algomaster99 changed the title Make boolean config parameters nullable to support three-state logic fix: support three-state logic for arguments May 26, 2026
@algomaster99 algomaster99 merged commit 29d0393 into main May 26, 2026
15 of 16 checks passed
@algomaster99 algomaster99 deleted the claude/kind-hopper-BW6CJ branch May 26, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants