Gradle: testDependents and testNeeded

With the gradle java plugin, you get the following tasks that are very neat:

buildDependents
buildNeeded

I would like to have similar tasks to run tests.

testDependents - Runs unit tests for this project and all projects that depend on it.
testNeeded - Run unit tests for this and all the projects on which it depends.

Is there any way to create such custom tasks in gradle?

+4
source share
1 answer

Got the following response from gradle forums.

allprojects { apply plugin:'java' task testDependents{ dependsOn (configurations.testRuntime.getTaskDependencyFromProjectDependency(false, "testDependents")) dependsOn test } task testNeeded{ dependsOn (configurations.testRuntime.getTaskDependencyFromProjectDependency(true, "testNeeded")) dependsOn test } } 
+2
source

Source: https://habr.com/ru/post/1442026/


All Articles