-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Added Gradle Wrapper support #12891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Gradle Wrapper support #12891
Conversation
1d1fb9a to
bca9d9d
Compare
90b0de3 to
ba37efc
Compare
gradle/lib/dependabot/gradle/file_parser/distributions_finder.rb
Outdated
Show resolved
Hide resolved
| module Distributions | ||
| extend T::Sig | ||
|
|
||
| DISTRIBUTIONS_URL = "https://services.gradle.org" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we detect this from the gradle-wrapper.properties?
In my current configuration, for example, this is pointing to a custom proxy. Example
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://example.com/gradle-distributions/gradle-9.0.0-bin.zip
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionBuildTime=20250731163512+0000There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty much intentional, because:
- The PR is aiming to support the 95% of the cases (if not more) where people use a standard Gradle distribution
- Even if I manage to infer the base URL for a non standard distribution, there won't be any guarantee that in that same server will exist an equivalent listing endpoint https://services.gradle.org/versions/all, or it will honor it's contact
Therefore the extra complexity to support this edge case won't pay off, at least in the scope of this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's understandable, but one of the core features of dependabot is the support for private registries, we may need to take that into account
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for making this change. It would be a great addition!
A few additional points regarding the review:
A key aspect of full Gradle wrapper support is regenerating the wrapper scripts (like gradlew and related files). If only the property file is updated and the scripts aren’t regenerated, it could cause issues.
In my view, a proper Gradle Wrapper upgrade should:
- Update the distribution property file
- Use the native Gradle binary to regenerate the wrapper scripts
- Commit both changes
For reference, see how the Update Gradle Wrapper Action handles this process.
As a side note, considering recent moves to separate ecosystems (such as npm and bum), it might be worth discussing if this should become its own ecosystem. I understand that gradle and the wrapper are related, but the structure and goal are different. Ultimately, however, it will be matter of opinion
I’ll leave that decision to the Dependabot team, as there are both advantages and disadvantages.
Thanks for the review @yeikel ! Let's wait for the maintainers feedback, but IMHO updating the whole set of scripts as that action does is just against the spirit of the tool itself. Not to mention it will be a technical challenge (or a blocker) to implement properly. I dig into this tool a few days ago, so I'm not an expert at all. But based on what I get from experience, it works with a "token replacement" approach. Implementing a proper script updating will require either to run Gradle or to do reverse engineering to the If a full update is required/desired, there are others tools for that or you can just do it manually yourself. There better "Gradle-native" approaches to update dependencies that does not has the flaws the Dependabot has. This tool just provides a static fast approach that fits in the 90% of the cases (again or even more). The wrapper updater just falls under the same pattern IMHO
In my experience, this has never happened. The wrapper API has been pretty stable from Gradle earlier versions
Well, IMHO I disagree. That Gradle has a different set of things to update, does not implies they are different ecosystems. If your thoughts are based on the Renovate approach, I'm not sure why it was implemented like that, but high-level, Gradle is just one. Its wrapper is just another kind of updatable component. |
I appreciate your perspective, though I see things a bit differently. Dependabot aims to align closely with native tools, which is why there’s a growing focus on integrating with each ecosystem’s native tooling, for example, regenerating lock files or running The wrapper-related files are part of the wrapper distribution, which is why the official documentation recommends using Gradle to update the wrapper. Dependabot should aim to create pull requests that are ready for immediate merging, without requiring manual intervention to finalize them. In this case, that'd would include all the related files to the wrapper
Yes, I'd think we should run gradle to execute the upgrade after we identify the version we are trying to upgrade to. From the docs: ./gradlew wrapper --gradle-version {gradleVersion}
Your experience may be limited to specific cases, but Gradle often makes changes for important reasons, such as updating the binary, improving Java version detection, or other enhancements. These updates go beyond simply keeping the wrapper functional; they are all part of the same distribution, and ensuring alignment across these components is essential. Keeping them out of sync may introduce issues that are hard to troubleshoot That said, the Dependabot team may welcome this initial version and use it to gather feedback. I would be among the first to raise an issue to ensure these files are generated for a more complete release. It doesn’t need to be included in the first iteration; we can release now and improve it over time. That's also a valid strategy
Although this is a subjective view, I believe there is a meaningful separation between the Gradle wrapper and application library dependencies. The wrapper and libraries follow different lifecycles: their versions are managed and detected in distinct ways, updated through separate processes, and the wrapper does not interact with registries or dependency resolution like application libraries do. Still, both are important parts of the Gradle ecosystem as you mentioned, and there are reasonable arguments for treating them together or separately depending on the situation. Ultimately, there are advantages and disadvantages to both approaches, and your perspective is valid as well |
Thanks for pointing that out, @yeikel. I just noted there are effective piece of code that run native tools, like I was originally reluctant to propose a solution like that, because running Now I think a complementary step may be added to use Let me see what I can do, or it can be done in a follow-up PR too. I'd like to get feedback from the maintainers about this as well. |
The good news is that both Java and Gradle come pre-installed in the Gradle containers, so no fallback is required. See dependabot-core/gradle/Dockerfile Lines 4 to 25 in 7da4bdd
|
ba37efc to
47f7faa
Compare
Awesome, thank you! I think that before this is reviewed, you should make sure that all the tests are passing as that'll be the first feedback you'll get 🙏 As of right now, the e2e smoke tests are failing |
I coudn't find documentation on how to work with the smoke tests. They are in a different repo. I have a PR for them as well, but changing Edit: |
06fb136 to
05127fe
Compare
Thanks @kbukum1! Assuming it's some kind whitelisting security check, make sure to also allow changes not just in |
|
@yeikel , |
|
@yeikel , Seems like you need to enable dependabot for https://github.com/yeikel/testcontainers-java |
|
It should be enabled now. Sorry for the confusion! |
|
Successfully enabled gradle_wrapper_updater on yeikel/testcontainers-java |
|
In one of the repositories, I am seeing the following failure
This seems to be a consequence of moving the build files around instead of running it from the root directly of the project. We'll have to find a workaround for that Full logs: https://github.com/yeikel/kafka-ui/actions/runs/19181649304/job/54839606560 edit: it seems that despite this error, the pull requests are still created 🤔 |
|
I am also seeing that other error you saw above
|
|
Hi team, sorry for being late. Support Gradle Wrapper feature flag rolled out 100%. I am planing to monitor for the day. Let me know if you get any issue. Also I will update the documentation accordingly. |
FIrst, I want to say I have been wanting this feature for a long time. However, I have a serious concern with how it's currently implemented. Dependabot is performing a full gradle wrapper update, which is modifying:
In many repositories, maintainers explicitly do not accept PRs that modify binary files. These changes are opaque in review and violate common security/contribution policies. Additionally, updating In my specific case, there is no easy way for me to independently verify that the
If dependabot limited the change to just
Unless I'm missing something, as it stands, this behavior forces me to block all gradle wrapper updates from dependabot, even though the version bumps themselves are desirable. Is there (or will there be) a way to limit updates to |
|
@Gamebuster19901 Fwiw, the https://github.com/gradle/actions#the-wrapper-validation-action will verify the gradle-wrapper.jar for you. |
|
Dependabot is working exactly as it should for most Gradle projects. I want all those files updated automatically by a predictable process. Many years ago I added The hashes are published at https://gradle.org/release-checksums and can be easily fetched via the URL The bash and bat files aren't binaries so you can review those as needed. |
Could you please log this as a separate feature request so it is tracked/discussed? |
I disagree. For my projects, I specifically don't want those files updated by anyone other than maintainers. It's just too risky. I self host all my CI, so I would still have to pull the (potentially malicious) commit onto my machine and verify the hash. If for some reason the file didn't match, then I would also have to purge it from the local repository history (and github, somehow?) as well.
I’m not very familiar with bash or batch scripting, honestly I don’t feel confident reviewing these files for subtle changes. I treat those files the same way I treat binaries. I would much rather run the wrapper update directly on my machine so I know all the files and binaries came directly from an official source. Basically my philosophy is that if it's coming directly from the official source, it's safe. If a binary is not coming directly from an official source, I treat it as unsafe. I don’t want dependabot to act as a middleman for updating binaries. I just want it to update version numbers, and I'll retrieve the binaries myself. That’s how it works for every other dependency I’ve used, and I’d like the Gradle wrapper to follow the same model. If changing the default behavior isn’t something you want to do, would you guys be open to adding a flag or configuration option to limit updates to |
|
@Gamebuster19901 that’s fine, but is is related to this feature? You don’t need to merge the PR but just use it as remainder to update Gradle by yourself. You can always force push the created PR. But anyway, the Gradle wrapper jars are signed via PGP, so you can check it. |
Dependabot already sets the SHA checksum: https://github.com/hfhbd/kotlinx-uuid/pull/510/changes But it requires to use the feature first. |
Awesome! That works for me then. |
|
I echo @Gamebuster19901's need to be able to disable the gradle wrapper updates.
When the PRs are created automatically individual teams may merge them, and waste time on troubleshooting and reverting. |
|
Hi all, Let's please move this discussion to the dedicated issue #2223 |
Dependabot now supports Gradle wrapper upgrades natively, making the custom GH workflow redundant dependabot/dependabot-core#12891

What are you trying to accomplish?
Introduces
Gradle Wrapperbump support forgradlemanagerCloses #2223 (issue open since 2018)
Smoke Tests PR: dependabot/smoke-tests#325
GitHub Docs PR: github/docs#39954
Anything you want to highlight for special attention from reviewers?
Following the same pattern used by
gradle/libs.version.tomlfile, we'll only look (and support) for agradle/wrapper/gradle-wrapper.propertiesin the root of the project.distributionSha256Sumis also supported, and it will only be updated if the original properties file has the property.Note
To minimize the risk of the feature and the impact on other smoke tests, I've introduced a new
gradle_wrapper_updaterfeature flag for this change.JAR binary and script files support
Updating other the
gradle-wrapper.jaror the companion shell scripts is done through the newWrapperUpdaterhelper by leveraging the existingLockfileUpdater.Most of its code was extracted into a new
GradleUpdaterBaseclass, which has two abstract methods:target_file?to tell the given file is meant to be updated by itcommand_argsto collaborate with the finalgradlecommand runNow both
LockfileUpdaterand the newWrapperUpdaterinherit fromGradleUpdaterBase.Note
The update will not attempt to use any configuration for the
wrappertask in the main build script; many of the repos will be broken because they rely on other files or included builds that will take a long time to complete. We limit to copying the wrapper-related files and running a clean, empty build.How will you know you've accomplished your goal?
Running against a sample repo:
produces the desired diff:
Checklist
Important
Do not squash this PR, so we won't the history of
lockfile_updater.rbbeing renamed togradle_updater_base.rband to attribute the original code to its autor.