Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration cache problems in Gradle 8.1 #225

Open
KENNYSOFT opened this issue Apr 13, 2023 · 12 comments
Open

Configuration cache problems in Gradle 8.1 #225

KENNYSOFT opened this issue Apr 13, 2023 · 12 comments

Comments

@KENNYSOFT
Copy link
Contributor

KENNYSOFT commented Apr 13, 2023

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
Copy link
Contributor Author

KENNYSOFT commented Apr 23, 2023

@KENNYSOFT
Copy link
Contributor Author

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:

Map<String, String> newMap = builder.generate(dotGitDirectory,
gitProperties.keys, gitProperties.dateFormat, gitProperties.dateFormatTimeZone, gitProperties.branch,
project.version, gitProperties.customProperties)

@imhansai
Copy link

+1

@jeantil
Copy link

jeantil commented Jan 18, 2024

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

@alexisgayte
Copy link

+1

@alexisgayte
Copy link

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

@dtrunk90
Copy link

dtrunk90 commented Feb 2, 2024

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

@artemptushkin
Copy link

artemptushkin commented Feb 28, 2024

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)

@randyhbh
Copy link

Is there any plan to support configuration cache soon? Currently using version 2.4.2 of this plugin and Gradle 8.10, I'm experiencing the following issues:

- [error] external process started `/usr/bin/git --version`
    - class `gradlegitproperties.org.eclipse.jgit.util.FS`
        - Exception at `gradlegitproperties.org.eclipse.jgit.util.FS.readPipe(FS.java:1357)`
- [error] external process started `/usr/bin/git config --system --edit`
    - class `gradlegitproperties.org.eclipse.jgit.util.FS`
        - Exception at `gradlegitproperties.org.eclipse.jgit.util.FS.readPipe(FS.java:1357)`
- [error] external process started `bash --login -c which git`
    - class `gradlegitproperties.org.eclipse.jgit.util.FS`
        - Exception at `gradlegitproperties.org.eclipse.jgit.util.FS.readPipe(FS.java:1357)`
- [error] external process started `xcode-select -p`
    - class `gradlegitproperties.org.eclipse.jgit.util.FS`
        - Exception at `gradlegitproperties.org.eclipse.jgit.util.FS.readPipe(FS.java:1357)`
- [error] invocation of `Task.project` at execution time is unsupported.
    - task `:app:generateGitProperties` of type `com.gorylenko.GenerateGitPropertiesTask`
        - Exception at `com.gorylenko.GenerateGitPropertiesTask_Decorated.getProperty(Unknown Source)`

@artemptushkin
Copy link

@randyhbh I don't this plugin will ever support anything, it was updated last time 2 years ago. It should be reported to Spring Boot so they stop refer it, people use the plugin but it's outdated - Gradle gets changed

@Igor-Mukhin
Copy link

Igor-Mukhin commented Oct 26, 2024

The issue is that the plugin's task collects the Git information during the Gradle's configuration phase. The problematic code is in the GenerateGitPropertiesTask:

  • getGeneratedProperties() is annotated with @Input and it executes the git command
  • getSource() is annotated with @InputFiles and it executes the git command

These executions have to be inside the @TestAction method.

I think a solution would be to:

  • Remove @Input* from the source and generatedProperties attributes
  • Add new attribute @InputFiles getGitInputFiles() that by default returns a collection of relevant Git files: .git/config, .git/HEAD, .git/refs/**
  • Move Git property resolution to the @TaskAction generate() method

@tha2015
Copy link
Collaborator

tha2015 commented Oct 26, 2024

Thanks. PRs are also welcomed :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants