Gradle released-versions json


(Sverre Moe) #1

What plugin or configuration does Gradle use to produce the released-version.json?
And also how it uses the version.txt to build releases.
released-versions.json
version.txt

I was thinking of setting up my project with similar files for releasing versions.

I see some references in the versioning.gradle, but I reckon it is not as easy just to use this file as it is.
versioning.gradle

It would have been a very nice plugin if Gradle had taken this out in a gradle-release-plugin.


(Stefan Wolf) #2

Hi Sverre,

you can find the plugin/tasks in the Gradle build itself: https://github.com/gradle/gradle/blob/07c80ec500ea43ac95bbed75bc562789bd582551/buildSrc/subprojects/versioning/src/main/kotlin/org/gradle/gradlebuild/versioning/UpdateVersionsPlugin.kt#L30

We read version.txt from here and then use it to determine the current version of all the projects.

The file released-versions.json is updated from our promotion job, every time we release a new version by the tasks added by the UpdateVersionsPlugin. The promotion build then also pushes the changes to our master branch.

We currently don’t plan to extract the versioning into a separate plugin.

Cheers,
Stefan


(Sverre Moe) #3

So the versioning.gradle, using the version.txt, handles the part about building either a snapshot, release candidate or release.
Then when building, either the milestoneNumber, rcNumber or finalRelease is provided as a property to the build.

gradle build -PmilestoneNumber=1
gradle build -PrcNumber=1
gradle build -PfinalRelease

What CI server do Gradle use?
How does the promotionBuild work?
  • Git change
    – CI builds a snapshot
  • Git change + version.txt
    – CI builds a release (rc or final)

The properties rcNumber and finalRelease must come from the CI, but how are they determined? It can’t be by parsing the version.txt, because that is read after the properties are read in versioning.gradle.


We are using Jenkins to build our projects with gradle.
Currently we are using git tags to determine to build either a snapshot or release.
  1. Manually create a git tag to release
  2. Jenkins detects the new git tag
  3. Manually start the tag build (this could though be done automatically in Jenkins)

Thus we do not need a version.txt to increment and get git commit for version bumps, but a person do need to inspect the git tags to determine the next version before tagging. Thought this could be done automatically with a gradle task.
gradle nextRelease
gradle nextRelease -PrcNumber=1