Test task has empty dependsOn in gradle 4.5


(Ryan Ernst) #1

When applying the java plugin, prior to gradle 4.5, the test task that is added had initial entry in dependsOn:

[task 'test' input files]

With gradle 4.5, dependsOn is now empty. Is this expected? We have our own test task which we swap out for the original. We used to simply take the dependsOn of the old test task and add those as dependsOn for the new test task, but since that is now an empty list, I guess we need to explicitly wire this up to the output of test compile?


(James Justinic) #2

The entry is technically still there in the dependencies, but the implementation was updated to store the immutable dependencies separately from the mutable dependencies. The returned value for dependsOn now only contains the mutable dependencies that you’re supposed to touch, which does complicate your case.


(Stefan Oehme) #3

The dependency you are referring to is there so the task depends on its own inputs. This should never have been user-removable, as it is required for basic correctness of a task.

Your task should properly declare its inputs (e.g. where the classes under test come from, what the classpath is etc). It will then automatically depend on the tasks that build those inputs. You should do that in any case, as otherwise up-to-date checking for your task would be broken.