Skip to content

Modernization, Phase 3: Lazy property access via Provider API and findProperty#291

Merged
OdysseusLives merged 6 commits intomainfrom
modernization
Feb 6, 2026
Merged

Modernization, Phase 3: Lazy property access via Provider API and findProperty#291
OdysseusLives merged 6 commits intomainfrom
modernization

Conversation

@OdysseusLives
Copy link
Copy Markdown
Member

Purpose

Replace eager property access (project.hasProperty(), project.property()) with Gradle’s lazy Provider API and findProperty() so that:

  • Configuration cache compatibility: Lazy evaluation avoids reading project state during configuration in a way that breaks the configuration cache.
  • Build performance: Property values are only resolved when needed instead of during configuration.
  • Consistency: One pattern for Gradle properties and project extras across the plugin.

Breaking changes

  • None for plugin users. Build scripts and existing use of the plugin do not need changes.
  • Internal API: UpdateDependenciesValidator.validate() no longer accepts project and extension; it now takes three boolean arguments. Only the plugin and tests call this; both were updated. Any other internal or third-party code that called validate(project, extension) must switch to the new signature and pass the resolved booleans.

Replace eager property access with lazy Provider API:
- lockAfterEvaluating: Use gradleProperty().orElse(extension)
- updateDependencies: Use gradleProperty().map().orElse(extension)
- overrideFile and override: Use gradleProperty().isPresent checks

Benefits:
- Lazy evaluation improves performance
- Gradle properties properly override extension
- Foundation for configuration cache compatibility
…nfigurer

Replace hasProperty/property with findProperty() inside provider:
- Maintains backward compatibility with both gradle properties and ext
- Uses modern provider API for lazy evaluation
- Cleaner than old conditional logic
Replace eager property access with lazy Provider API:
- shouldLockAllConfigurations: Use gradleProperty().map().getOrElse()
- additionalConfigurationsToLock: Use gradleProperty().map().getOrElse()

Benefits:
- Lazy evaluation during construction
- Consistent Provider API usage across codebase
- Foundation for configuration cache compatibility
…erty

Replace eager hasProperty/property access with findProperty():
- readOverrides(): Use findProperty() for OVERRIDE_FILE
- readOverrides(): Use findProperty() for dependencyLock.override

Benefits:
- Maintains backward compatibility with both gradle properties and ext
- Cleaner than hasProperty/property pattern
- readOverrides() is called during configuration phase from Plugin.apply()
…pt properties

Eliminate project.hasProperty/property calls by refactoring:
- Remove project and extension parameters from validate()
- Accept three boolean validation flags as direct parameters
- Update DependencyLockPlugin to resolve properties using Provider API
- Update all test calls to pass resolved boolean values

Benefits:
- No more eager property access during validation
- Cleaner separation of concerns (caller resolves properties)
- Validation logic is now pure and testable
- Consistent with Provider API pattern
…findProperty

Replace eager hasProperty/property access with findProperty():
- verifySuccessfulResolution(): Use findProperty() for CONFIGURATIONS_TO_EXCLUDE
- unresolvedDependenciesShouldFailTheBuild(): Use findProperty() for fail flag

Benefits:
- Single API call instead of hasProperty() + property()
- Null-safe by design (returns null vs throwing exception)
- Checks both gradle properties (-P) and project extras (ext)
- Modern Gradle API recommended approach
@OdysseusLives OdysseusLives merged commit 480b93e into main Feb 6, 2026
3 checks passed
@OdysseusLives OdysseusLives deleted the modernization branch February 6, 2026 22: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.

1 participant