kt3k / coveralls-gradle-plugin

👨‍🔧 gradle plugin for coveralls
https://plugins.gradle.org/plugin/com.github.kt3k.coveralls
MIT License
253 stars 54 forks source link

How to get badge to display #57

Closed tgsmith61591 closed 8 years ago

tgsmith61591 commented 8 years ago

Hey, I used your coveralls wrapper on my java project and it worked seamlessly. Thank you so much! My question (and it's likely an extremely naive one...) is how to get the coverage badge? It seems like it didn't execute on coveralls.

Here is my repo. Here's what my .travis.yml file looks like:

language: java
jdk:
  - oraclejdk7

branches:
  only:
    - master

before_script:
 - "echo $JAVA_OPTS"
 - "export JAVA_OPTS=-Xmx512m"

after_failure:
  - cat target/surefire-reports/*.txt

before_cache:
  - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock

cache:
  directories:
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/

after_success:
- ./gradlew cobertura coveralls

And I have the following line at the head of my build.gradle:

plugins {
    // ... other plugins
    // coverage tools
    id 'net.saliman.cobertura' version '2.3.1'
    id 'com.github.kt3k.coveralls' version '2.6.3'
}
cobertura.coverageFormats = ['html', 'xml'] // coveralls plugin depends on xml format report

And yet, I'm still getting the coverage | unknown badge in my README. Any thoughts?

kt3k commented 8 years ago

.travis.yml and the above part of build.gradle seem ok to me.

I looked at this build ( https://travis-ci.org/tgsmith61591/clust4j/builds/122092556 ) and ./gradlew cobertura coveralls seems failing at :test phase because of NoClassDefFoundErrors. (Try click $ ./gradlew cobertura coveralls part of travis console log).

Maybe classpaths are different when you test with coverage and without coverage.

tgsmith61591 commented 8 years ago

Ah, you're absolutely right. I didn't even catch that portion of the log. After doing some digging around, it looks like there is a well-known issue with Cobertura causing these, though they profess it should have stopped in 2.3... There are also a lot of unanswered questions about this on StackOverflow. I'll keep digging around; if you have any ideas, I'd really appreciate your guidance.

kt3k commented 8 years ago

I recommend you should try JaCoCo plugin instead of cobertura if it's difficult to debug.

tgsmith61591 commented 8 years ago

Thanks, I went with JaCoCo and per this usecase, just sent the results to codecov with curl.