gradle-cobertura-plugin
gradle-cobertura-plugin copied to clipboard
Cannot instrument Gradle tasks
Hi, First of all, thank you for developing this great plugin. I’m using this plugin in some of my projects, but when I apply this to my Gradle plugin project, the coverage of some classes are very low.
First, I wrote my dependencies in build.gradle
like this:
dependencies {
compile gradleApi()
compile localGroovy()
testCompile 'junit:junit:4.12'
}
which results in this warning logs:
$ ./gradlew clean cobertura
...
:instrument
Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
Unable to instrument file /Users/xxx/Workspace/issues/github/gradle-cobertura-plugin/gradle-task/build/instrumented_classes/com/example/greeting/GreetingTask.class
java.lang.NoClassDefFoundError: org/gradle/util/Configurable
...
Caused by: java.lang.ClassNotFoundException: org.gradle.util.Configurable
The instrument
task succeeded, but the line coverage of the task is zero.
So I tried adding gradleApi()
dependency to cobertura
configuration:
dependencies {
compile gradleApi()
compile localGroovy()
testCompile 'junit:junit:4.12'
cobertura gradleApi()
}
The Configurable
class was resolved, but I got the following error and the cobertura
task failed.
$ ./gradlew clean cobertura
...
:instrument
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/xxx/.gradle/wrapper/dists/gradle-2.7-all/4ryh47z6pv2tj9n03uiw8pzc6/gradle-2.7/lib/gradle-core-2.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/xxx/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.0.13/6b56ec752b42ccfa1415c0361fb54b1ed7ca3db6/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
Failed to instantiate SLF4J LoggerFactory
Reported exception:
java.lang.NoClassDefFoundError: org/slf4j/spi/LoggerFactoryBinder
...
Caused by: java.lang.ClassNotFoundException: org.slf4j.spi.LoggerFactoryBinder
Do you have any ideas to handle this issue?
I’ve looked into some SLF4J related issues in this project
(adding SLF4J dependency to testRuntime
etc.),
but couldn’t solve this problem...
I made a very simple project to confirm this issue, so you can try this if you need.
$ git clone https://github.com/ksoichiro/issues.git
$ cd issues/github/gradle-cobertura-plugin/gradle-task
$ ./gradlew clean cobertura
My environment:
- Mac OS X 10.10.1
- Oracle JDK 7 (1.7.0_51)
- Gradle 2.7 (Gradle wrapper)
Thanks