CompareGradleBuilds Feature

Introduces Gradle’s CompareGradleBuilds task for validating upgrade impact by comparing build outputs across Gradle versions. Includes guidance for customizing task sets and understanding current comparison limitations.

Coveros Staff

October 7, 2015

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.

Coveros Staff

Coveros Staff

This post represents the collective insights of the Coveros team. Our staff consists of software experts who bring deep experience in secure agile development, DevOps, testing, and software quality. Over the past 20 years, Coveros has trained more than 30,000 professionals and worked with half of the Fortune 100 companies on mission-critical software development challenges. We draw on this extensive experience to share practical insights, proven strategies, and real-world solutions that help organizations build better software faster and more securely.