clover not picking all the java files for instrumentation - using gradle build

I have a very big multi project gradle project and I am trying to execute clover on it. I am facing an issue with the instrumentation of the files, the clover is not picking all the files to be instrumented,. The package contains around 10 files and I see only 4 files instrumented at the source-instr folder. 

 

dependencies {
  testCompile 'junit:junit:4.12'
}
sourceSets {
  clover {
    java {
      srcDir "$buildDir/sources-instr"
    }
  }
}

dependencies {
  cloverCompile 'com.atlassian.clover:clover:4.0.6'
}
configurations { 
  cloverCompile.extendsFrom compile
}
configurations {
  cloverRuntime
  cloverRuntime.extendsFrom cloverCompile
}

task cloverInstr() {
  inputs.files sourceSets.main.allJava 
  outputs.dir "$buildDir/sources-instr"

  doFirst {
    def argsList = ["--initstring", "${rootProject.projectDir}/clover/clover.db",
"-d", "${buildDir}/sources-instr"]
    argsList.addAll(inputs.files.files.collect({ file ->
file.absolutePath
}))
    String[] args = argsList.toArray()
    com.atlassian.clover.CloverInstr.mainImpl(args)
  }
}


cloverInstr.onlyIf { project.hasProperty('clover') }
cloverClasses.dependsOn cloverInstr

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

task cloverReport {
  inputs.dir "${buildDir}/clover"
  outputs.dir "${reportsDir}/clover"
  onlyIf {
    file("${buildDir}/clover/clover.db").exists()
  }
  doFirst {
    def argsList = ["--initstring", "${rootProject.projectDir}/clover/clover.db",
"-o", "${reportsDir}/clover/clover.xml","-a"]
    String[] args = argsList.toArray()
    com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
    // com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
  }
}

1 answer

This widget could not be displayed.

Are you sure you have all sources in main sources set? As far I can see there's nothing wrong with the setup, but in order to cloverInstr task pick up all source it has to have all sources defined as an input files. Especially, if you generate sources somewhere, then you need to pass them to cloverInstr as-well.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

121 views 2 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you