Testing Gradle task order with --dry-run and BuildResult


(Appu Goundan) #1

I notice something weird when upgrading my plugin build.
It looks like some behavior has changed since 3.4.1 -> 4.9 (but basically 3.5+)

BuildResult buildResult = GradleRunner.create()....withArguments("assemble", "--dry-run").build();

/* expected */ buildResult.getTasks().size == 5
/* actual   */ buildResult.getTasks().size == 0

Why do I care? I used to use this to check build order.

Assert.assertEquals([":compile", ":assemble"], someFilter(buildResult.getTasks()))

Why did BuildResult change to not include skipped tasks in the build result?
I can still parse the output presumably, but that is less that ideal.

I must’ve been misusing the result, is there a cleaner way to test build order?


(Stefan Oehme) #2

dry-run no longer does any execution at all. It just prints the task graph in topological order.