How to change the "version" property depending on the project build status "up-to-date"?

I’m thinking of changing the manifest of a jar or the jar name itselfs every time some changes are detected. I.e. so long a “gradle build” prints “up-to-date” I want to keep the jar name unchanged. In all other cases I want to create a new version.

Hopefully it is clear what I’m looking for.

I tried like

subprojects {

version = new Date().format(“yyyyMMdd-mm-tt-ss”)

… }

but then, every time a new jar is built, which is clear to me after rethinking it. But how could a solution to my problem look like?

Hope you can help.

Thanks, Leif

About changing the manifest without re-generating the jar - there was already a similar question - how one could exclude certain manifest headers from the up-to-date check, see Input files upTodate-check customization. About jar filename - I think that if you change the version, the jar task will always re-execute as it checks whether the output jar file is available or not. You could probably change the filename after the jar task executes, but then you will have to also adjust the name of the artifact that it adds to the ArtifactHandler, otherwise you will not be able to upload this artifact and other projects will not be able to resolve it.

In the Gradle build, we use the modification date of the most recently modified source file. This is a reasonable approximation, and avoids this problem.

thank you for the pointer, this is what i was looking for.