I am a newbie to Gradle, Cobertura, and Sonar and I am trying to get them to play together nicely. I noticed that sometimes on my Sonar dashboard, my unit test success is 100.0% for 34 tests and other times it just reports 0 tests. After some amount of digging, I found that
This works fine gradle build gradle cobertura sonar
This causes sonar to report 0 tests gradle build cobertura sonar
Why does it matter if I call them together or separately?
And upon some further digging, I found that sometimes my gradle generated unit test reports at build/reports/tests/index.html are there and sometimes they aren’t. And in fact
This works fine gradle build gradle cobertura
This causes the unit test reports to disappear (or to never be created?) gradle build cobertura
Any ideas would be greatly appreciated!
Thanks, WhatWouldHoneyBadgerDo
Here is my version information
$ gradle -v
------------------------------------------------------------
Gradle 1.0-milestone-8
------------------------------------------------------------
Gradle build time: Monday, February 13, 2012 11:53:32 PM UTC
Groovy: 1.8.4
Ant: Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Ivy: 2.2.0
JVM: 1.6.0_31 (Sun Microsystems Inc. 20.6-b01)
OS: Linux 2.6.9-89.0.11.ELlargesmp amd64
Here is my build script
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'
apply plugin: 'sonar'
sourceCompatibility = 1.6
version = '1.0'
implementationTitle = 'NameChangedToProtectTheInnocent'
/*
createWrapper creates gradle-wrapper.jar, gradle-wrapper.properties, gradlew, gradlew.bat
*/
task createWrapper(type: Wrapper) {
gradleVersion = '1.0-milestone-8'
distributionBase = Wrapper.PathBase.PROJECT
archiveBase = Wrapper.PathBase.PROJECT
}
repositories {
mavenCentral()
}
dependencies {
compile("log4j:log4j:1.2.16")
compile("org.apache.httpcomponents:httpclient:4.1.3")
compile("org.springframework:spring-web:3.1.1.RELEASE")
testCompile("junit:junit:4.10")
}
jar {
manifest {
attributes 'Implementation-Title': implementationTitle, 'Implementation-Version': version
}
}
sonar {
project {
coberturaReportPath = file("$buildDir/reports/cobertura/coverage.xml")
}
}
/*
Apply cobertura plugin for code coverage in sonar
This will add the 'cobertura' task which instruments the code,
executes the tests and outputs to build/reports/cobertura.
*/
buildscript {
def githubBase = 'https://raw.github.com/valkolovos/gradle_cobertura/master/ivy'
apply from: "${githubBase}/gradle_cobertura/gradle_cobertura/1.0-rc4/coberturainit.gradle"
}