gradle-git-properties icon indicating copy to clipboard operation
gradle-git-properties copied to clipboard

Configuration cache problems in Gradle 8.1

Open KENNYSOFT opened this issue 2 years ago • 12 comments

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

KENNYSOFT avatar Apr 13 '23 04:04 KENNYSOFT

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.

KENNYSOFT avatar Apr 23 '23 12:04 KENNYSOFT

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 Project methods.

Instead of: Use:
project.version A task input or output property or a script variable to capture the result of using project.version to 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

KENNYSOFT avatar Apr 23 '23 12:04 KENNYSOFT

+1

imhansai avatar Jan 11 '24 07:01 imhansai

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

jeantil avatar Jan 18 '24 12:01 jeantil

+1

alexisgayte avatar Jan 23 '24 11:01 alexisgayte

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

alexisgayte avatar Jan 30 '24 10:01 alexisgayte

Another workaround to consider until this plugin supports configuration cache: Setting org.gradle.configuration-cache.problems=warn in gradle.settings.

dtrunk90 avatar Feb 02 '24 22:02 dtrunk90

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)

artemptushkin avatar Feb 28 '24 13:02 artemptushkin