gradle-git-versioning-plugin icon indicating copy to clipboard operation
gradle-git-versioning-plugin copied to clipboard

Fix compatibility with Gradle `8.1` and Configuration Cache

Open gmazzo opened this issue 2 years ago • 20 comments

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.

gmazzo avatar Apr 25 '23 11:04 gmazzo

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? 🤔

gmazzo avatar Apr 25 '23 14:04 gmazzo

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: image

gmazzo avatar Apr 26 '23 07:04 gmazzo

Hey, I got corona :-/ so probably I'll look a this next week.

qoomon avatar Apr 26 '23 10:04 qoomon

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.

gmazzo avatar Apr 26 '23 10:04 gmazzo

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.

aSemy avatar Apr 30 '23 09:04 aSemy

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

qoomon avatar Apr 30 '23 17:04 qoomon

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 avatar May 03 '23 09:05 gmazzo

@gmazzo maybe you can provide a simple project to reproduce the error?

qoomon avatar May 04 '23 07:05 qoomon

@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 avatar May 07 '23 09:05 gmazzo

@gmazzo thanks a lot that works or actually it doesn't :-D

qoomon avatar May 08 '23 07:05 qoomon

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.

qoomon avatar May 08 '23 10:05 qoomon

Same here, I think it should be caused by some static initialization of jgit.

gmazzo avatar May 08 '23 11:05 gmazzo

I don't know how to reset it after it work once.

qoomon avatar May 08 '23 12:05 qoomon

even after removing .git and .gradle dir it still works

qoomon avatar May 08 '23 12:05 qoomon

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

gmazzo avatar May 08 '23 14:05 gmazzo

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 :/

deblockt avatar Jul 04 '24 06:07 deblockt

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.

qoomon avatar Jul 04 '24 10:07 qoomon