I was reading through some Gradle documentation, and I came across this task CompareGradleBuilds. What this task does is it runs your build on the current version of Gradle, and then runs the build on a different specified version of Gradle, and produces a report that says if the builds are identical or not. I found this to be a very cool, and it could be a very practical way of testing a Gradle upgrade; however, I couldn’t really find any tutorials explaining how to set it up, and all I had was the API. Also once I found the API, I struggled through a couple of the more advanced features of this task. For example, the default tasks that CompareGradleBuilds runs on each version is “clean, assemble”, so if you want to run a different set of tasks then you must explicitly define them. One thing to note is that currently, this feature compares only the zip archives that are generated (this includes jar war, and ear archives). If you wish to run a different set of tasks other than “clean, assemble” you can define the tasks in the following way:

compareGradleBuilds {
sourceBuild.setGradleVersion("2.0")
sourceBuild.setTasks(['clean','uploadArchives'] as LinkedList)
targetBuild.setGradleVersion("2.8")
targetBuild.setTasks(['clean','uploadArchives'] as LinkedList)
}

Although this task is only able to compare the zip archives, Gradle does plan to be able to compare test execution outcomes. Until then, you could still include your test tasks, and compare by parsing through the logging.

Leave a comment

Your email address will not be published. Required fields are marked *

X