Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How does test execution creates a dependency on clover tasks in gradle?

Avinav Sharan June 18, 2018

As per the instructions here: https://confluence.atlassian.com/clover/gradle-clover-plugin-317950477.html , integrating clover manually, one of the steps is:

test execution - add clover.jar to the test classpath

test {
    def cloverClasspath = configurations.testRuntime + configurations.cloverRuntime + sourceSets.test.output + sourceSets.clover.output
    classpath = cloverClasspath
}

How does this work? I have noticed, somehow adding the clover jar in test task's classpath, pulls in cloverInstr and compileCloverJava tasks.

1 answer

0 votes
Avinav Sharan June 18, 2018

It most probably works because inferred task dependencies (https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:inferred_task_dependencies) in gradle.

Because `sourceSets.clover.output` is added to the classPath of the `test` task, gradle resolves it by adding a task dependency.

Grzegorz Lewandowski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 19, 2018

Generally speaking, Gradle can figure out task dependencies basing on task inputs/outputs.

Since test task depends on: 

* sourceSets.test.output

* sourceSets.clover.output

Gradle knows Test task is needs to invoke testClasses (testCompile + testProcessResources) and cloverClasses first because those are the tasks which generate output of a source set. 

As it goes about clover.jar. Configuration cloverRuntime contains it so test task classpath contains it as well. Nothing super fancy here ;)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events