palantir / gradle-jacoco-coverage

Apache License 2.0
99 stars 25 forks source link

Missing jar dependency #9

Closed dbmalkovsky closed 9 years ago

dbmalkovsky commented 9 years ago

I found I had to add a classpath dependency of the form:

classpath "com.google.guava:guava:+"

to my build.gradle file to get jacoco-coverage to work.

Without the jar I see messages like:

Failed to apply plugin [id 'com.palantir.jacoco-coverage'] Could not create an instance of type com.palantir.jacoco.JacocoCoverageExtension_Decorated.

dbmalkovsky commented 9 years ago

Turning on --stacktrace the root cause is:

Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/ArrayListMultimap at com.palantir.jacoco.JacocoCoverageExtension.(JacocoCoverageExtension.groovy:38) at com.palantir.jacoco.JacocoCoverageExtension_Decorated.(Unknown Source) at org.gradle.internal.reflect.DirectInstantiator.newInstance(DirectInstantiator.java:49)

uschi2000 commented 9 years ago

Thanks for reporting this, @dbmalkovsky. Will fix this asap and let you know. R

uschi2000 commented 9 years ago

@dbmalkovsky , this fixes the problem you described for me in a simple sample project. I am a bit annoyed the integration tests didn't catch this problem... I will merge&release soon unless you report that this commit doesn't fix your problem. Thanks again for reporting this!

dbmalkovsky commented 9 years ago

On inspection the fix looks correct.

But to be sure I cloned the repository and applied your fix to the gradle.build file. I then ran "gradle build" and got test failures. Please see the log file below. I'm assuming I've done something wrong or there is another dependency missing.

$ git clone https://github.com/palantir/gradle-jacoco-coverage.git Cloning into 'gradle-jacoco-coverage'... remote: Counting objects: 324, done. d 0 (delta 0), pack-reused 323 Receiving objects: 100% (324/324), 114.21 KiB | 0 bytes/s, done. Resolving deltas: 100% (117/117), done. Checking connectivity... done.

sasdbm@d7b520 MINGW64 ~/dev $ cd gradle-jacoco-coverage

sasdbm@d7b520 MINGW64 ~/dev/gradle-jacoco-coverage (master) $ ls CHANGELOG.md LICENSE README.md build.gradle build.gradle~ gradle/ gradlew* gradlew.bat settings.gradle src/

sasdbm@d7b520 MINGW64 ~/dev/gradle-jacoco-coverage (master) $ gradle build Download https://jcenter.bintray.com/com/palantir/gradle-flexversion/0.7.0/gradle-flexversion-0.7.0.pom Download https://jcenter.bintray.com/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.2/gradle-bintray-plugin-1.2.pom Download https://plugins.gradle.org/m2/com/gradle/publish/plugin-publish-plugin/0.9.1/plugin-publish-plugin-0.9.1.pom Download https://jcenter.bintray.com/org/eclipse/jgit/org.eclipse.jgit.java7/3.4.1.201406201815-r/org.eclipse.jgit.java7-3.4.1.201406201815-r.pom Download https://jcenter.bintray.com/org/eclipse/jgit/org.eclipse.jgit-parent/3.4.1.201406201815-r/org.eclipse.jgit-parent-3.4.1.201406201815-r.pom Download https://jcenter.bintray.com/org/codehaus/groovy/modules/http-builder/http-builder/0.7.2/http-builder-0.7.2.pom Download https://jcenter.bintray.com/oauth/signpost/oauth-signpost/1.2.1.2/oauth-signpost-1.2.1.2.pom Download https://jcenter.bintray.com/oauth/signpost/signpost-commonshttp4/1.2.1.2/signpost-commonshttp4-1.2.1.2.pom Download https://jcenter.bintray.com/org/apache/httpcomponents/httpclient/4.2.2/httpclient-4.2.2.pom Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcomponents-client/4.2.2/httpcomponents-client-4.2.2.pom Download https://jcenter.bintray.com/com/google/code/gson/gson/2.2.4/gson-2.2.4.pom Download https://jcenter.bintray.com/org/apache/maven/maven-core/3.0.4/maven-core-3.0.4.pom Download https://jcenter.bintray.com/org/eclipse/jgit/org.eclipse.jgit/3.4.1.201406201815-r/org.eclipse.jgit-3.4.1.201406201815-r.pom Download https://jcenter.bintray.com/net/sf/json-lib/json-lib/2.3/json-lib-2.3.pom Download https://jcenter.bintray.com/net/sourceforge/nekohtml/nekohtml/1.9.16/nekohtml-1.9.16.pom Download https://jcenter.bintray.com/xml-resolver/xml-resolver/1.2/xml-resolver-1.2.pom Download https://jcenter.bintray.com/oauth/signpost/signpost-core/1.2.1.2/signpost-core-1.2.1.2.pom Download https://jcenter.bintray.com/org/apache/maven/maven-settings/3.0.4/maven-settings-3.0.4.pom Download https://jcenter.bintray.com/org/apache/maven/maven-settings-builder/3.0.4/maven-settings-builder-3.0.4.pom Download https://jcenter.bintray.com/org/apache/maven/maven-artifact/3.0.4/maven-artifact-3.0.4.pom Download https://jcenter.bintray.com/org/apache/maven/maven-plugin-api/3.0.4/maven-plugin-api-3.0.4.pom Download https://jcenter.bintray.com/org/sonatype/sisu/sisu-inject-plexus/2.3.0/sisu-inject-plexus-2.3.0.pom Download https://jcenter.bintray.com/org/sonatype/sisu/inject/guice-plexus/2.3.0/guice-plexus-2.3.0.pom Download https://jcenter.bintray.com/org/sonatype/sisu/inject/guice-bean/2.3.0/guice-bean-2.3.0.pom Download https://jcenter.bintray.com/org/sonatype/sisu/inject/containers/2.3.0/containers-2.3.0.pom Download https://jcenter.bintray.com/org/sonatype/sisu/sisu-inject/2.3.0/sisu-inject-2.3.0.pom Download https://jcenter.bintray.com/org/sonatype/sisu/sisu-parent/2.3.0/sisu-parent-2.3.0.pom Download https://jcenter.bintray.com/commons-beanutils/commons-beanutils/1.8.0/commons-beanutils-1.8.0.pom Download https://jcenter.bintray.com/net/sf/ezmorph/ezmorph/1.0.6/ezmorph-1.0.6.pom Download https://jcenter.bintray.com/xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.pom Download https://jcenter.bintray.com/org/sonatype/sisu/sisu-inject-bean/2.3.0/sisu-inject-bean-2.3.0.pom Download https://jcenter.bintray.com/org/sonatype/sisu/sisu-guice/3.1.0/sisu-guice-3.1.0.pom Download https://jcenter.bintray.com/org/sonatype/sisu/inject/guice-parent/3.1.0/guice-parent-3.1.0.pom Download https://jcenter.bintray.com/org/sonatype/sisu/sisu-guava/0.9.9/sisu-guava-0.9.9.pom Download https://jcenter.bintray.com/org/sonatype/sisu/inject/guava-parent/0.9.9/guava-parent-0.9.9.pom Download https://jcenter.bintray.com/com/palantir/gradle-flexversion/0.7.0/gradle-flexversion-0.7.0.jar Download https://jcenter.bintray.com/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.2/gradle-bintray-plugin-1.2.jar Download https://plugins.gradle.org/m2/com/gradle/publish/plugin-publish-plugin/0.9.1/plugin-publish-plugin-0.9.1.jar Download https://jcenter.bintray.com/org/eclipse/jgit/org.eclipse.jgit.java7/3.4.1.201406201815-r/org.eclipse.jgit.java7-3.4.1.201406201815-r.jar Download https://jcenter.bintray.com/org/codehaus/groovy/modules/http-builder/http-builder/0.7.2/http-builder-0.7.2.jar Download https://jcenter.bintray.com/oauth/signpost/signpost-commonshttp4/1.2.1.2/signpost-commonshttp4-1.2.1.2.jar Download https://jcenter.bintray.com/org/apache/httpcomponents/httpclient/4.2.2/httpclient-4.2.2.jar Download https://jcenter.bintray.com/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar Download https://jcenter.bintray.com/org/apache/maven/maven-core/3.0.4/maven-core-3.0.4.jar Download https://jcenter.bintray.com/org/eclipse/jgit/org.eclipse.jgit/3.4.1.201406201815-r/org.eclipse.jgit-3.4.1.201406201815-r.jar Download https://jcenter.bintray.com/net/sf/json-lib/json-lib/2.3/json-lib-2.3-jdk15.jar Download https://jcenter.bintray.com/net/sourceforge/nekohtml/nekohtml/1.9.16/nekohtml-1.9.16.jar Download https://jcenter.bintray.com/xml-resolver/xml-resolver/1.2/xml-resolver-1.2.jar Download https://jcenter.bintray.com/oauth/signpost/signpost-core/1.2.1.2/signpost-core-1.2.1.2.jar Download https://jcenter.bintray.com/org/apache/maven/maven-settings/3.0.4/maven-settings-3.0.4.jar Download https://jcenter.bintray.com/org/apache/maven/maven-settings-builder/3.0.4/maven-settings-builder-3.0.4.jar Download https://jcenter.bintray.com/org/apache/maven/maven-artifact/3.0.4/maven-artifact-3.0.4.jar Download https://jcenter.bintray.com/org/apache/maven/maven-plugin-api/3.0.4/maven-plugin-api-3.0.4.jar Download https://jcenter.bintray.com/org/sonatype/sisu/sisu-inject-plexus/2.3.0/sisu-inject-plexus-2.3.0.jar Download https://jcenter.bintray.com/commons-beanutils/commons-beanutils/1.8.0/commons-beanutils-1.8.0.jar Download https://jcenter.bintray.com/net/sf/ezmorph/ezmorph/1.0.6/ezmorph-1.0.6.jar Download https://jcenter.bintray.com/xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar Download https://jcenter.bintray.com/org/sonatype/sisu/sisu-inject-bean/2.3.0/sisu-inject-bean-2.3.0.jar Download https://jcenter.bintray.com/org/sonatype/sisu/sisu-guice/3.1.0/sisu-guice-3.1.0-no_aop.jar Download https://jcenter.bintray.com/org/sonatype/sisu/sisu-guava/0.9.9/sisu-guava-0.9.9.jar Download https://jcenter.bintray.com/org/codehaus/plexus/plexus-utils/2.1/plexus-utils-2.1.jar :compileJava UP-TO-DATE :compileGroovy :processResources :classes :jar :groovydoc :publishPluginGroovyDocsJar :publishPluginJar :javadoc :publishPluginJavaDocsJar :assemble :compileTestJava UP-TO-DATE :compileTestGroovy Download https://jcenter.bintray.com/org/hamcrest/hamcrest-all/1.3/hamcrest-all-1.3.pom Download https://jcenter.bintray.com/com/netflix/nebula/nebula-test/2.2.1/nebula-test-2.2.1.pom Download https://jcenter.bintray.com/org/spockframework/spock-core/1.0-groovy-2.3/spock-core-1.0-groovy-2.3.pom Download https://jcenter.bintray.com/cglib/cglib-nodep/2.2.2/cglib-nodep-2.2.2.pom Download https://jcenter.bintray.com/org/codehaus/groovy/groovy-all/2.3.10/groovy-all-2.3.10.pom Download https://jcenter.bintray.com/org/hamcrest/hamcrest-all/1.3/hamcrest-all-1.3.jar Download https://jcenter.bintray.com/com/netflix/nebula/nebula-test/2.2.1/nebula-test-2.2.1.jar Download https://jcenter.bintray.com/org/spockframework/spock-core/1.0-groovy-2.3/spock-core-1.0-groovy-2.3.jar Download https://jcenter.bintray.com/cglib/cglib-nodep/2.2.2/cglib-nodep-2.2.2.jar Download https://jcenter.bintray.com/org/codehaus/groovy/groovy-all/2.3.10/groovy-all-2.3.10.jar :processTestResources :testClasses :test

com.palantir.jacoco.JacocoCoveragePluginTest > check task depends on checkCoverage task FAILED java.lang.NoSuchMethodError at JacocoCoveragePluginTest.groovy:48

com.palantir.jacoco.JacocoCoveragePluginTest > check fails when coverage is required FAILED java.lang.NoSuchMethodError at JacocoCoveragePluginTest.groovy:65

com.palantir.jacoco.JacocoCoveragePluginTest > checkCoverage succeeds when no coverage is required FAILED java.lang.NoSuchMethodError at JacocoCoveragePluginTest.groovy:81

com.palantir.jacoco.JacocoCoveragePluginTest > All syntax variations work FAILED java.lang.NoSuchMethodError at JacocoCoveragePluginTest.groovy:105

com.palantir.jacoco.JacocoCoveragePluginTest > Violations are reported for every realm FAILED java.lang.NoSuchMethodError at JacocoCoveragePluginTest.groovy:123

com.palantir.jacoco.JacocoFullReportPluginTest > jacoco-full-report can exclude sub projects FAILED java.lang.NoSuchMethodError at JacocoFullReportPluginTest.groovy:141

com.palantir.jacoco.JacocoFullReportPluginTest > jacoco-full-report reports on union of execution data FAILED java.lang.NoSuchMethodError at JacocoFullReportPluginTest.groovy:152

com.palantir.jacoco.JacocoFullReportPluginTest > jacoco-full-report works when only some subprojects provide execution data FAILED java.lang.NoSuchMethodError at JacocoFullReportPluginTest.groovy:166

com.palantir.jacoco.JacocoFullReportPluginTest > jacocoFullReport object has non-null sourceDirectories even when task did not run FAILED java.lang.NoSuchMethodError at JacocoFullReportPluginTest.groovy:194

20 tests completed, 9 failed :test FAILED

FAILURE: Build failed with an exception.

BUILD FAILED

Total time: 1 mins 16.79 secs

sasdbm@d7b520 MINGW64 ~/dev/gradle-jacoco-coverage (master) $

uschi2000 commented 9 years ago

Which Gradle version are you using to build this? Can you try running it with the Gradle wrapper please: ./gradlew build

dbmalkovsky commented 9 years ago

My bad; sorry; I was running with gradle verison 2.6.

Using the Gradle wrapper (version 2.4); I get 3 failures:

com.palantir.jacoco.JacocoFullReportPluginTest > jacoco-full-report reports on union of execution data FAILED org.gradle.api.GradleException at JacocoFullReportPluginTest.groovy:152 Caused by: org.gradle.internal.exceptions.LocationAwareException Caused by: org.gradle.api.tasks.TaskExecutionException Caused by: org.gradle.process.internal.ExecException

com.palantir.jacoco.JacocoFullReportPluginTest > jacoco-full-report works when only some subprojects provide execution data FAILED org.gradle.api.GradleException at JacocoFullReportPluginTest.groovy:166 Caused by: org.gradle.internal.exceptions.LocationAwareException Caused by: org.gradle.api.tasks.TaskExecutionException Caused by: org.gradle.process.internal.ExecException

com.palantir.jacoco.JacocoFullReportPluginTest > jacocoFullReport object has non-null sourceDirectories even when task did not run FAILED org.gradle.api.GradleException at JacocoFullReportPluginTest.groovy:194 Caused by: org.gradle.internal.exceptions.LocationAwareException Caused by: org.gradle.api.tasks.TaskExecutionException Caused by: org.gradle.process.internal.ExecException

20 tests completed, 3 failed :test FAILED

uschi2000 commented 9 years ago

Which OS is this on?

dbmalkovsky commented 9 years ago

Running a Git bash shell on Windows 7 Enterprise

uschi2000 commented 9 years ago

I don't currently have the capacity to test/debug the plugin on Windows, I'm afraid. I assume that is has to do with path handling somewhere; would you be willing to dig into this and provide a fix? Note that the bug is in the jacoco-full-report plugin which is entirely independent from the jacoco-coverage plugin.

dbmalkovsky commented 9 years ago

Not having much luck tracking this down but I can report a few things:

(1) My backup process last night complained about long path names; for example:

C:\dev\gradle-jacoco-coverage\build\test\com.palantir.jacoco.JacocoCoveragePluginTest\checkCoverage-succeeds-when-no-coverage-is-required_1\build\tmp\expandedArchives\org.jacoco.agent-0.7.1.201405082137.jar_30wtixh9mgaatafl9baarfeub\META-INF\maven The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

(2) When I run with --debug I find an issue with Jar manifest missing and a pipe closing; here is an example:

Starting process 'Gradle Test Executor 1'. Working directory: C:\dev\gradle-jacoco-coverage\build\test\com.palantir.jacoco.JacocoFullReportPluginTest\jacoco-full-report-reports-on-union-of-execution-data_11\testFooA Command: C:\Java\bin\java.exe -Djava.security.manager=jarjar.org.gradle.process.internal.child.BootstrapSecurityManager -javaagent:build/tmp/expandedArchives/org.jacoco.agent-0.7.1.201405082137.jar_30wtixh9mgaatafl9baarfeub/jacocoagent.jar=destfile=build/jacoco/test.exec,append=true,dumponexit=true,output=file,jmx=false -Dfile.encoding=windows-1252 -Duser.country=US -Duser.language=en -Duser.variant -ea -cp C:\Users\sasdbm\.gradle\caches\2.4\workerMain\gradle-worker.jar jarjar.org.gradle.process.internal.launcher.GradleWorkerMain 'Gradle Test Executor 1'
     Successfully started process 'Gradle Test Executor 1'

com.palantir.jacoco.JacocoFullReportPluginTest > jacoco-full-report reports on union of execution data STANDARD_ERROR
     Error opening zip file or JAR manifest missing : build/tmp/expandedArchives/org.jacoco.agent-0.7.1.201405082137.jar_30wtixh9mgaatafl9baarfeub/jacocoagent.jar

 com.palantir.jacoco.JacocoFullReportPluginTest > jacoco-full-report reports on union of execution data STANDARD_OUT
     Error occurred during initialization of VM
     agent library failed to init: instrument

 com.palantir.jacoco.JacocoFullReportPluginTest > jacoco-full-report reports on union of execution data STANDARD_ERROR
     Could not write standard input into: Gradle Test Executor 1.

     java.io.IOException: The pipe is being closed
          at java.io.FileOutputStream.writeBytes(Native Method)
          at java.io.FileOutputStream.write(FileOutputStream.java:326)
          at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
          at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
          at org.gradle.process.internal.streams.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:50)
          at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
          at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          at java.lang.Thread.run(Thread.java:745)

 com.palantir.jacoco.JacocoFullReportPluginTest > jacoco-full-report reports on union of execution data STANDARD_OUT
     :testFooA:test
     FAILED

     :testFooA:test (Thread[Connection worker,5,main]) completed. Took 0.075 secs.

 com.palantir.jacoco.JacocoFullReportPluginTest > jacoco-full-report reports on union of execution data STANDARD_ERROR

     FAILURE:
     Build failed with an exception.

     * What went wrong:
     Execution failed for task ':testFooA:test'.
     >
     Process 'Gradle Test Executor 1' finished with non-zero exit value 1
dbmalkovsky commented 9 years ago

Looks like this was addressed with pull request #10 on Aug 31, 2015. Closing.

gdulus commented 8 years ago

Hey, in which version this issue has been fixed? I'm using version 0.3.0 and I'm getting:

Caused by: org.gradle.internal.reflect.ObjectInstantiationException: Could not create an instance of type com.palantir.jacoco.JacocoCoverageExtension_Decorated.
    at org.gradle.internal.reflect.DirectInstantiator.newInstance(DirectInstantiator.java:51)
    at org.gradle.api.internal.ClassGeneratorBackedInstantiator.newInstance(ClassGeneratorBackedInstantiator.java:36)
    at org.gradle.api.internal.plugins.DefaultConvention.create(DefaultConvention.java:106)
    at com.palantir.jacoco.JacocoCoveragePlugin.apply(JacocoCoveragePlugin.groovy:38)
    at com.palantir.jacoco.JacocoCoveragePlugin.apply(JacocoCoveragePlugin.groovy)
    at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyImperative(ImperativeOnlyPluginApplicator.java:35)
    at org.gradle.api.internal.plugins.RuleBasedPluginApplicator.applyImperative(RuleBasedPluginApplicator.java:43)
    at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
    ... 61 more
Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/ArrayListMultimap
    at com.palantir.jacoco.JacocoCoverageExtension.<init>(JacocoCoverageExtension.groovy:38)
    at com.palantir.jacoco.JacocoCoverageExtension_Decorated.<init>(Unknown Source)
    at org.gradle.internal.reflect.DirectInstantiator.newInstance(DirectInstantiator.java:49)
    ... 68 more
uschi2000 commented 8 years ago

We hadn't actually made a release with the fix. Just released 0.4.0 now.