mirror of
https://github.com/spring-projects/spring-security.git
synced 2026-03-24 19:11:04 +00:00
Previously, the `CheckExpectedBranchVersionPlugin` would crash the Gradle configuration phase if the project was in a detached HEAD state or not in a Git repository, e.g., downloaded as a ZIP. This commit refactors the plugin to be lazy and adopts several Gradle best practices: - Prevents build crashes on Git failures by gracefully catching non-zero exit codes, e.g., when checked out in a detached HEAD state. - Moves the branch validation out of the task's main execution action and into an `onlyIf` predicate, allowing Gradle to skip the task entirely instead of executing an early return. This makes the skip outcome and reason visible in a Build Scan, rather than making it appear as if it executed. - Defers the Git `exec` call to the execution phase using a lazy provider. - Makes the task configuration cache compatible by avoiding illegal `Project` access inside the execution-time `onlyIf` closure. - Improves user-facing logs and adds actionable bypass instructions when the project version doesn't match the branch version. Signed-off-by: Eric Haag <ehaag@gradle.com>