4

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

buildDependents
buildNeeded

I would like to have similar tasks for running tests only.

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

Can I somehow create such custom tasks in gradle?

4

1 回答 1

3

从 gradle 论坛得到以下答案。

allprojects {
    apply plugin:'java'
    task testDependents{
        dependsOn (configurations.testRuntime.getTaskDependencyFromProjectDependency(false, "testDependents"))
        dependsOn test
    }
    task testNeeded{
        dependsOn (configurations.testRuntime.getTaskDependencyFromProjectDependency(true, "testNeeded"))
       dependsOn test
    }
}
于 2012-11-02T08:32:48.273 回答