There are a multitude of ways to control the Gradl...
# community-support
j
There are a multitude of ways to control the Gradle dependency resolution process. Is there any guidance or best practices for organizing Gradle builds to support automated dependency vulnerability remediation via tools like dependabot? If we assume the tool already has access to resolved dependencies and knows the non-vulnerable version required for the fix, how do we organize the Gradle build to enable the tool to create a successful pull request?
v
I'd use a version catalog and if you insist on using such bots, then at least Renovate instead of Dependabot.
j
What alternatives are there to using such bots?
v
I don't like my pull-requests spammed with continuous minor version updates and also don't want to handle dozens of pull-requests each week. But if a project does not handle them, it easily appears to be unmaintained, whether it is or not.
I also don't see much value in doing so for some intermediate project like a library.
I prefer doing dependency updates when I choose to do them. If I want some programmatic support, I usually have a combination of Ben Manes versions plugin to display what is up-to-date and out-of-date, and the refreshVersions plugin to ease the update process. And if I want to have some nagging for pending updates, I just make a cron-sheduled workflow that fails if there are updates available.
But to each his preferred toolset
Just if you want to use such a dependency bot, at least use the better one
j
I'm not so interested in staying up-to-date with the latest available versions. I want to resolve vulnerabilities as soon as feasible. Most of the time, a simple version upgrade is all that's required. What I'm finding is all of the bots rely on versions explicitly specified in the Gradle files somewhere. If you use a BOM in a platform to manage versions and the BOM contains a vulnerable dependency, then the bots can't help you. The same is true for transitive dependencies. The bots don't understand Gradle dependency management. They only try a search and replace. Other than explicitly specifying the version for all direct and transitive dependencies in a project, I'm wondering what approaches others have taken or if there is some best practice around this?
v
If that is true, I'd report a bug against those tools. If they want to properly support Gradle, they should use the tooling API to get the versions used in the project. But actually, Ben Manes versions plugin is a Gradle plugin and it uses the dependency resolution of Gradle to find new versions, basically by copying configurations, using "latest" versions for things and then resolving them. So approaches like that should properly work including any dependency resolution configuration you can make. But also that afair only checks the versions of things you depend on, not transitive dependencies.
Yep, but they are open for a PR that adds checking transitive versions too: https://github.com/ben-manes/gradle-versions-plugin/issues/530 😉
e
arbitrary build scripts are turing-complete so there's no guaranteed way to change a version
v
Maybe not to change, but at least to detect
And as it is for his own project as far as I understood, he could also follow rules that make the update possible. And how to "best" do that was actually the main question afaiu 🙂
e
well there's no guarantee that an arbitrary build script will depend on the same version more than once either 😉
v
I didn't get that
e
but yeah as long as there's no strange module metadata rules or resolution strategies or
withDependencies
mutation, things should be pretty normal
j
> arbitrary build scripts are turing-complete so there's no guaranteed way to change a version But can we be successful in a large percentage of cases? Are there rules we can follow to increase success?
e
a goal of #C06JG95HREY is to make editing builds mechanical and reliable
it's not ready but if you can stick to similar principles you'll be in a better place
v
But can we be successful in a large percentage of cases?
Sure, but if you want to use a specific tool that updates the versions for you, then make sure you use things that are compatible with that tool.