generateGitProperties fails on property 'projectVersion' with release 2.5.0
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'
}
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
I was able to work around this issue using following.
generateGitProperties {
projectVersion = project.version.toString()
}
I didn't manage to fix this.
The workaround didn't work for me initially. Changing to lazy evaluation did the trick.
generateGitProperties {
projectVersion = "${-> project.version}"
}
Any ideas how to fix it in gradle kts?
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() })
}
}
}