Replace version of JGit used by Gradle itself

Is there a way of changing the version of JGit that Gradle itself uses?

Gradle uses JGit for handling source dependencies. I’ve seen issues (e.g. when Git repo directories change to symlinks) which might be fixed in newer JGit versions.

I’m guessing the version of JGit that is used is specified here. Can I override it without changing this file and recompiling Gradle? Is specifying a newer JGit as a settings.gradle script dependency the way?

I have no idea, but I highly doubt it.
I think it is in some other class loader that is not related to the settings script class path.
Otherwise it might have made problems with other plugins using JGit in their implementation.

But if you have a custom distribution anyway, you could maybe just swap the JGit jar file in it without the need to recompile the whole distribution. At least if the version is backwards compatible and does not need code changes.

But as the feature also did not develop for years and also is not an officially supported feature anyway, you might want to look at alternatives like for example Included Git repositories plugin for Gradle