gradle-git-versioning-plugin
gradle-git-versioning-plugin copied to clipboard
Fix compatibility with Gradle `8.1` and Configuration Cache
Since Gradle 8.1, any exec command that is not done trough providers is forgiven at configuration time:
FAILURE: Build failed with an exception.
* What went wrong:
Configuration cache problems found in this build.
2 problems were found storing the configuration cache.
- Build file 'plugin/build.gradle.kts': external process started '/opt/homebrew/bin/git --version'
See https://docs.gradle.org/8.1.1/userguide/configuration_cache.html#config_cache:requirements:external_processes
- Build file 'plugin/build.gradle.kts': external process started '/opt/homebrew/bin/git config --system --show-origin --list -z'
See https://docs.gradle.org/8.1.1/userguide/configuration_cache.html#config_cache:requirements:external_processes
See the complete report at file:///xxx/configuration-cache-report.html
> Starting an external process '/opt/homebrew/bin/git --version' during configuration time is unsupported.
> Starting an external process '/opt/homebrew/bin/git config --system --show-origin --list -z' during configuration time is unsupported.
Researching a bit deeper, it seems this is actually caused by JGIT implementation, I am right? I thought JGIT was a pure java implementation, why is running the host git command? 🤔
I'd say this issue is caused by JGit and every plugin that relies on it will face the same. It seems it's accessing .gitconfig on ins initialization by a couple of git commands and that is causing to Gradle's Configuration Cache to fail:

Hey, I got corona :-/ so probably I'll look a this next week.
Yeah no hurries. I was talking a look and it seems there is no way no hook on jgit to delegate the process creation to Gradle's exec.
So one option will be to ask for it, or open a PR, but probably is going to be a long process.
Another one will be to check if you can not depend on it at all, and just make raw git commands with exec.
I hope you feel better soon @qoomon!
I think what might work is putting every JGit calls inside a ValueSource, to be computed lazily. That should allow Gradle to fingerprint the property.
Unfortunately I am not able to reproduce the issue :-/
I run ./gradlew --configuration-cache version multiple times, without any error
Gradle Version: 8.1.1
Plugin Version: 6.4.2
Felling better right? Sorry I missed that comment 😅
Unfortunately I am not able to reproduce the issue :-/
That's strange 🤔, maybe it's not done all the time? I think it's worth wrapping it in a provider anyway, as the GIT case is actually their main example of it
I have too much on my plate right now (between work, personal plugins, and other contributions) but I'll keep it in the agenda for later if no one else can do it.
@gmazzo maybe you can provide a simple project to reproduce the error?
@gmazzo maybe you can provide a simple project to reproduce the error?
Here is it: https://github.com/gmazzo/gradle-git-versioning-plugin-cc-issue
Run ./gradlew --stop && ./gradlew build to get the issue.
Here is a scan of it also: https://scans.gradle.com/s/bs5gyy43tlebc
@gmazzo thanks a lot that works or actually it doesn't :-D
It's totally strange to me, it fails the first time i run ./gradlew version the second time it works just as expected.
Even if I remove the ./gradle folder it still works.
Same here, I think it should be caused by some static initialization of jgit.
I don't know how to reset it after it work once.
even after removing .git and .gradle dir it still works
I don't know how to reset it after it work once.
Kill the daemon, that worked to me every time: ./gradlew --stop && ./gradlew xxx
Hi, I have the same issue with gradle 8.5 . On local I have successfully fix the issue removing .gradle directory, but it's fail on github actions :/
sorry for the inconvenience. Unfortunately it is a big refactoring and I'm not familiar with gradle cache mechanism. And I don't have the time to fix that currently. So every PR is appreciated.