Skip to content

gradle: Fix wrapper updater to update all 4 wrapper files#13578

Closed
kbukum1 wants to merge 1 commit into
mainfrom
kamil/gradle-fix-wrapper-update-all-files
Closed

gradle: Fix wrapper updater to update all 4 wrapper files#13578
kbukum1 wants to merge 1 commit into
mainfrom
kamil/gradle-fix-wrapper-update-all-files

Conversation

@kbukum1
Copy link
Copy Markdown
Contributor

@kbukum1 kbukum1 commented Nov 17, 2025

What are you trying to accomplish?

This PR fixes the Gradle wrapper updater to update all 4 wrapper files (gradlew, gradlew.bat, gradle-wrapper.jar, and gradle-wrapper.properties) instead of only updating the gradle-wrapper.properties file.

Why: The current implementation only updates the properties file, leaving the wrapper scripts and JAR at the old version. This causes build inconsistencies and defeats the purpose of updating the wrapper.

Related Issue: #13501

Anything you want to highlight for special attention from reviewers?

Key implementation decisions:

  1. Two-step wrapper execution: Following Gradle's official documentation, the wrapper task must be run twice:

    • First run: Downloads the new Gradle distribution
    • Second run: Regenerates wrapper binaries with the new distribution
  2. Use ./gradlew instead of gradle: The project's wrapper should be used, not the system Gradle installation, to ensure consistency.

  3. Binary file handling: Added proper support for binary files (gradle-wrapper.jar) using Base64 encoding/decoding and binread/binwrite.

  4. Error handling: Changed from silent failure (puts) to raising DependencyFileNotResolvable following Dependabot standards (matches bundler, npm, python ecosystems).

  5. File permissions: Ensured gradlew scripts are executable (chmod 0o755).

  6. Return pattern: Returns all dependency_files with wrapper files replaced (matches the LockfileUpdater pattern in the same codebase).

How will you know you've accomplished your goal?

Tests added:

  • ✅ Wrapper task runs twice in sequence
  • ✅ Error handling raises DependencyFileNotResolvable on failure
  • ✅ Non-wrapper dependencies don't trigger wrapper updater
  • ✅ All 4 wrapper files are processed (including binaries)

Test results:

@github-actions github-actions Bot added the L: java:gradle Maven packages via Gradle label Nov 17, 2025
…r handling

- Consolidate wrapper update logic into dedicated methods for clarity.
- Ensure both wrapper update commands are executed in sequence.
- Add error handling for wrapper task failures, raising DependencyFileNotResolvable.
- Update specs to verify command execution and handle wrapper updates correctly.
@kbukum1 kbukum1 force-pushed the kamil/gradle-fix-wrapper-update-all-files branch from 93c109f to fbb6910 Compare November 17, 2025 23:18
@kbukum1
Copy link
Copy Markdown
Contributor Author

kbukum1 commented Nov 18, 2025

Duplicate: #13579 #13579

@kbukum1 kbukum1 closed this Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L: java:gradle Maven packages via Gradle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant