gradle-git-properties
gradle-git-properties copied to clipboard
Configuration cache problems in Gradle 8.1
Error:
* What went wrong: Configuration cache problems found in this build.
3 problems were found storing the configuration cache. - Class `gradlegitproperties.org.eclipse.jgit.util.FS`: external process started '/usr/bin/git --version' See https://docs.gradle.org/8.1/userguide/configuration_cache.html#config_cache:requirements:external_processes - Class `gradlegitproperties.org.eclipse.jgit.util.FS`: external process started '/usr/bin/git config --system --edit' See https://docs.gradle.org/8.1/userguide/configuration_cache.html#config_cache:requirements:external_processes - Task `:generateGitProperties` of type `com.gorylenko.GenerateGitPropertiesTask`: invocation of 'Task.project' at execution time is unsupported. See https://docs.gradle.org/8.1/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution
build.gradle (extracted):
plugins {
id 'java'
id 'org.springframework.boot' version '3.0.5'
id 'io.spring.dependency-management' version '1.1.0'
id 'com.gorylenko.gradle-git-properties' version '2.4.1'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
vendor = JvmVendorSpec.AZUL
}
}
gitProperties {
dateFormat = 'yyyy-MM-dd\'T\'HH:mm:ss'
dateFormatTimeZone = 'Asia/Seoul'
}
gradle.properties (extracted):
org.gradle.configuration-cache=true
References for issues related to JGit:
- diffplug/spotless#1644
- https://discuss.gradle.org/t/using-jgit-with-gradle-configuration-cache/45410
Seems to be able to detour using environment variable GIT_CONFIG_NOSYSTEM.
https://docs.gradle.org/8.1.1/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution
The following table shows what APIs or injected service should be used as a replacement for each of the
Projectmethods.
Instead of: Use: project.versionA task input or output property or a script variable to capture the result of using project.versionto calculate the actual parameter.
The root cause is here:
https://github.com/n0mer/gradle-git-properties/blob/80fd874532d027bc74e5b2e7acea3b1abfd3d577/src/main/groovy/com/gorylenko/GenerateGitPropertiesTask.groovy#L96-L98
+1
one of my colleagues dug up a jgit feature that makes this plugin config-cache compatible with no code changes
using the GIT_CONFIG_NOSYSTEM environment key, jgit will not try to read the system wide git config and in out initial tests this was enough to make v2.4.1 work with the config cache
another option is to change the way jgit is initialized in the plugin ( maybe with an associated config property ) like it has been done in this PR for the axion release plugin https://github.com/allegro/axion-release-plugin/pull/683/files
+1
For Information this plugin is working for me :
"io.hndrs.gradle:gradle-git-properties-plugin:1.0.0"
https://plugins.gradle.org/plugin/io.hndrs.git-properties
Another workaround to consider until this plugin supports configuration cache: Setting org.gradle.configuration-cache.problems=warn in gradle.settings.
I think it's important to mention another plugin https://github.com/hndrs/gradle-git-properties-plugin (it was mentioned above indeed)
This one was updated 2 years ago, it has MRs open for N years and it has a low response in issues, tbh I have serious doubts about why Spring refers to it even in latest versions
- Gradle build cache doesn't work properly here, see my issue
- Gradle configuration cache doesn't work either (it can be an underlying library problem but still)