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

generateGitProperties fails on property 'projectVersion' with release 2.5.0

Open aggeboe opened this issue 9 months ago • 6 comments

The generateGitProperties task fails with

Execution failed for task ':generateGitProperties'.
> Cannot fingerprint input property 'projectVersion': value '3.20.0-SNAPSHOT' cannot be serialized.

and

plugins {
    id 'com.gorylenko.gradle-git-properties' version '2.5.0'
}

Works fine with

plugins {
    id 'com.gorylenko.gradle-git-properties' version '2.4.2'
}

aggeboe avatar Mar 07 '25 09:03 aggeboe

We see this on every project as well. We are using Nebula Release to manage our versions

What went wrong: Execution failed for task ':batch-application:generateGitProperties'. Cannot fingerprint input property 'projectVersion': value '1.209.0-dev.2.a17737a' cannot be serialized.

also using version 2.5.0

plugins {
    id "com.gorylenko.gradle-git-properties" version "2.5.0"
}

and gradle version 8.13 distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip

pauldburton avatar Apr 03 '25 13:04 pauldburton

I was able to work around this issue using following.

  generateGitProperties {
    projectVersion = project.version.toString()
  }

tanvirp avatar Jul 15 '25 23:07 tanvirp

I didn't manage to fix this.

alinaeftn avatar Aug 11 '25 16:08 alinaeftn

The workaround didn't work for me initially. Changing to lazy evaluation did the trick.

generateGitProperties {
    projectVersion = "${-> project.version}"
}

schup avatar Aug 14 '25 07:08 schup

Any ideas how to fix it in gradle kts?

skyfall174 avatar Sep 18 '25 12:09 skyfall174

I'm using jgitver to calculate project version and it seems then the value isn't anymore simple String but an object that isn't serializable. So solution is that the gradle-git-properties plugin converts whatever verison object to simple String representation. Or that other plugins like jgitver or nebula provide serializable objects representing project versions.

for the time being I use

allprojects {
    plugins.withId('com.gorylenko.gradle-git-properties') {
        tasks.withType(com.gorylenko.GenerateGitPropertiesTask).configureEach {
            projectVersion.set(providers.provider { project.version.toString() })
        }
    }
}

rivancic avatar Sep 19 '25 10:09 rivancic