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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

clover 4 with gradle

I am using the build.gradle provided by you . The issue I am facing is that the source files are not being picked up. The clover directory is not getting created and hence the report is not getting generated.  The command I am using is ./gradlew clean test cloverInstr cloverReport. 

Could you please help me . My project structure is:

Root Project
     A (child)
     B (child)
     C (child)
apply plugin: 'java'
apply plugin: 'maven'


repositories {
  jcenter()
  maven {
    url "Our internal repo"
  }
}

dependencies {
  testCompile 'junit:junit:4.12'
}

buildscript {
  repositories {
    jcenter()
    // mavenCentral()
    //mavenLocal()
    maven {
      url "our internal repo"
    }
  }
  dependencies {
    classpath 'com.atlassian.clover:clover:4.1.1'
  }
}

sourceSets {
  clover {
    java {
      srcDir "$buildDir/sources-instr"
    }
  }
}


dependencies {
  cloverCompile 'com.atlassian.clover:clover:4.1.1'
}

configurations {
  cloverRuntime
  cloverRuntime.extendsFrom cloverCompile
}

task cloverInstr() {
  inputs.files sourceSets.main.allJava
  println "The source set is"
  println "${sourceSets.main}"
  outputs.dir "$buildDir/sources-instr"
  doFirst {
    def argsList = ["--initstring", "${buildDir}/clover/clover.db",
"-d", "${buildDir}/sources-instr"]
    argsList.addAll(inputs.files.files.collect({ file ->
      file.absolutePath
      println "In doFirts"
    }))
    String[] args = argsList.toArray()
    println "the args list is"
    println "${args}"
    com.atlassian.clover.CloverInstr.mainImpl(args)
  }
}

cloverClasses.dependsOn cloverInstr


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

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

1 answer

1 accepted

1 vote
Answer accepted

Hi, you should do the source instrumentation before testing it. I think the implicit dependencies between outputs of cloverInstr and inputs of test should handle it, but potentially they don't

I would try running 

./gradlew clean cloverInstr test cloverReport

 

Hi Grzegorz 

Thanks for your response. I ve been trying with 

./gradlew clean cloverInstr test cloverReport 

The clover.db is created and the instrumentation is done. 

The issue that Im facing now is compilation fails for the files at source-instr files. The failure is due to the packages missing , like the import statements are not fetching the packages in the source-instr folder. 

test {

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

}

 

Is there a way to to add the source-instr to the classpath 

 

I guess none of the main sources dependencies are picked up when you try to compile Clover sources set.  So when Gradle compiles cloverSourceSet, it takes cloverCompile configuration.

And as far I can see, you don't configure any dependencies on that configuration. I think you're missing the following code snippet:

configurations {

cloverCompile.extendsFrom compile

}

 

Thankyou!! ...that worked :smile:

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Jira Cloud Performance Improvements

Hello everyone, I am a product manager in the Jira Cloud team focused on making sure our customers have a delightful experience using our products. Towards that goal, one of the areas which is extr...

171 views 2 9
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you