Problems with sonar and jacoco plugin integration


(dhruv.jrt) #1

I have the following project setup:

project ├─src

// source files here ├─test

// test files here ├─test-lib

// test libs here eg. junit ├─container-lib // libs bundled with app servers ├─jacoco-lib // jacoco libs │ ├─jacocoagent.jar │ ├─jacocoant.jar │ ├─org.jacoco.agent-0.6.3.201306030806.jar │ ├─org.jacoco.ant-0.6.3.201306030806.jar │ ├─org.jacoco.core-0.6.3.201306030806.jar │ └─org.jacoco.report-0.6.3.201306030806.jar └─WebContent // web-content html, js, css, jsp

└─WEB-INF

├─lib

// project libs

└─web.xml

Following is my build.gradle (some trivial parts removed)

apply plugin: "war"
apply plugin: "jacoco"
apply plugin: "sonar"
  repositories {
 flatDir {
  dirs = ["jacoco-lib"]
 }
}
  sourceSets {
 main.java.srcDirs = ["src"]
 test.java.srcDirs = ["test"]
}
  dependencies {
 compile fileTree(dir: "WebContent/WEB-INF/lib", include: "*.jar")
 providedCompile fileTree(dir: "container-lib", include: "*.jar")
 testCompile fileTree(dir: "test-lib", include: "*.jar")
 testRuntime fileTree(dir: "jacoco-lib", include: "*.jar")
}
  sonar {
 server.url = "http://mysonarserver.com/sonar"
 database {
  url = "jdbc:mysql://<db ip address>:<port>/sonarqube?useUnicode=true&amp;characterEncoding=utf8"
  driverClassName = "com.mysql.jdbc.Driver"
  username = "sonar"
  password = "sonar"
 }
 project {
  key = "com.group.project"
   name = "${project.name}"
  description = "Some description"
  language = "java"
  sourceEncoding = "UTF-8"
  dynamicAnalysis
= "reuseReports"
  withProjectProperties { props ->
   props["sonar.core.codeCoveragePlugin"] = "jacoco"
   props["sonar.jacoco.itReportPath"] = "${buildDir}/jacoco/jacocoIt.exec"
   props["sonar.jacoco.reportPath"] = "${buildDir}/jacoco/jacoco.exec"
  }
 }
}
  jacoco {
 toolVersion = "0.6.3.201306030806"
}

Additionally following is the output at http://mysonarserver.com/sonar/batch xstream-1.3.1.jar,sonar-batch-3.7.1.jar,sonar-graph-3.7.1.jar,plexus-interpolation-1.11.jar,slf4j-api-1.6.2.jar,sonar-squid-3.7.1.jar,plexus-utils-1.5.15.jar,commons-codec-1.8.jar,picocontainer-2.14.3.jar,sonar-markdown-3.7.1.jar,sonar-plugin-api-3.7.1.jar,geronimo-spec-jta-1.0-M1.jar,sonar-batch-maven-compat-3.7.1.jar,maven-artifact-2.2.0.jar,hibernate-commons-annotations-3.1.0.GA.jar,sonar-colorizer-3.7.1.jar,jcl-over-slf4j-1.6.2.jar,sonar-update-center-common-1.8.jar,akiban-persistit-3.2.7.jar,hibernate-annotations-3.4.0.GA.jar,javassist-3.4.GA.jar,sonar-check-api-3.7.1.jar,commons-lang-2.6.jar,mybatis-3.1.1.jar,maven-artifact-manager-2.2.0.jar,commons-digester-1.8.jar,gson-2.2.4.jar,stax2-api-3.0.1.jar,commons-dbcp-1.4.jar,guava-10.0.1.jar,wagon-provider-api-1.0-beta-6.jar,backport-util-concurrent-3.1.jar,antlr-2.7.6.jar,staxmate-2.0.0.jar,json-simple-1.1.1.jar,plexus-container-default-1.0-alpha-9-stable-1.jar,sonar-deprecated-3.7.1.jar,sonar-channel-3.7.1.jar,commons-io-2.4.jar,commons-configuration-1.6.jar,dom4j-1.6.1.jar,sonar-core-3.7.1.jar,hibernate-entitymanager-3.4.0.GA.jar,logback-classic-0.9.30.jar,xpp3-1.1.3.3.jar,maven-plugin-registry-2.2.0.jar,jsr305-1.3.9.jar,maven-model-2.2.0.jar,maven-repository-metadata-2.2.0.jar,xml-apis-1.3.03.jar,maven-profile-2.2.0.jar,logback-core-0.9.30.jar,plexus-classworlds-2.2.3.jar,junit-4.10.jar,ejb3-persistence-1.0.2.GA.jar,serializer-2.7.1.jar,commons-dbutils-1.5.jar,commons-beanutils-1.8.3.jar,sonar-java-api-3.7.1.jar,h2-1.3.172.jar,woodstox-core-lgpl-4.0.4.jar,sonar-home-3.7.1.jar,maven-settings-2.2.0.jar,sonar-duplications-3.7.1.jar,blueprints-core-2.2.0.jar,commons-pool-1.5.4.jar,xercesImpl-2.8.1.jar,stax-api-1.0.1.jar,maven-project-2.2.0.jar,hibernate-core-3.3.2.GA.jar,hamcrest-core-1.1.jar,xalan-2.7.1.jar,commons-collections-3.2.1.jar,jcommon-1.0.12.jar,log4j-over-slf4j-1.6.2.jar

gradle sonarAnalyze

gives the following error (with stacktrace)

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':sonarAnalyze'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:283)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$1.run(DefaultTaskPlanExecutor.java:33)
        at org.gradle.internal.Factories$1.create(Factories.java:22)
        at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:214)
        at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:276)
        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:142)
        at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.longRunningOperation(DefaultTaskArtifactStateCacheAccess.java:78)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:31)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:86)
        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
        at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
        at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
        at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
        at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:46)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.Main.main(Main.java:37)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.lang.NullPointerException: null value
        at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:204)
        at com.google.common.collect.ImmutableMap.entryOf(ImmutableMap.java:139)
        at com.google.common.collect.ImmutableMap$Builder.put(ImmutableMap.java:178)
        at com.google.common.collect.Maps.fromProperties(Maps.java:594)
        at org.sonar.batch.bootstrapper.Batch.<init>(Batch.java:59)
        at org.sonar.batch.bootstrapper.Batch.<init>(Batch.java:37)
        at org.sonar.batch.bootstrapper.Batch$Builder.build(Batch.java:173)
        at org.sonar.batch.Batch.execute(Batch.java:103)
        at org.sonar.batch.Batch$execute.call(Unknown Source)
        at org.gradle.api.plugins.sonar.internal.SonarCodeAnalyzer.execute(SonarCodeAnalyzer.groovy:51)
        at org.gradle.api.plugins.sonar.internal.SonarCodeAnalyzer$execute.call(Unknown Source)
        at org.gradle.api.plugins.sonar.SonarAnalyze.analyze(SonarAnalyze.groovy:49)
        at org.gradle.util.JavaMethod.invoke(JavaMethod.java:62)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:219)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:212)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:201)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:527)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:510)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
        ... 49 more

Any idea on how to resolve this? Or clues on what might be wrong?


(Benjamin Muschko) #2

Would you mind providing a project on GitHub that reproduces the issue?

Some of the Sonar properties you don’t actually need to set yourself. They are either default values or are set by the Sonar plugin.


(dhruv.jrt) #3

Here is a sample project to replicate the issue: https://github.com/d3vel0per/gradle-issues.git

The project uses a standalone sonar server running on localhost ie. with the default configuration. Here is the link to the download: http://dist.sonar.codehaus.org/sonar-3.7.2.zip

Both of the tasks sonarAnalyze and jacocoTestReport will fail.


(Peter Niederwieser) #4

You are using the old Sonar plugin, which, as documented in the user guide, doesn’t work with recent Sonar versions. Try the ‘sonar-runner’ plugin instead.


(dhruv.jrt) #5

@Peter Thanks for the tip. Got the sonar issue resolved. But the target jacocoTestReport still fails. I am able to guess it is a dependency related issue but not able to resolve it. I have updated the project on github https://github.com/d3vel0per/gradle-issues.git

Additionally please share if there is a better way to resolve jacoco libs. In my sample, I feel lines 8-12 and line 35 are redundant.


(Peter Niederwieser) #6

Please provide detailed information on the error that you are getting. The docs don’t mention putting jacoco libs on the ‘testRuntime’ class path, so I think that’s redundant.


(dhruv.jrt) #7

Here is the detailed stacktrace:

FAILURE: Build failed with an exception.
  * What went wrong:
Execution failed for task ':jacocoTestReport'.
> taskdef A class needed by class org.jacoco.ant.ReportTask cannot be found: org/jacoco/core/analysis/ICoverageVisitor
 using the classloader AntClassLoader[E:\development\sources\gradle-issues\jacoco-lib\org.jacoco.ant-0.6.3.201306030806.jar]
  * Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':jacocoTestReport'.
 at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
 at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
 at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
 at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
 at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
 at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
 at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
 at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
 at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
 at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:283)
 at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
 at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
 at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
 at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$1.run(DefaultTaskPlanExecutor.java:33)
 at org.gradle.internal.Factories$1.create(Factories.java:22)
 at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:214)
 at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:276)
 at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:142)
 at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.longRunningOperation(DefaultTaskArtifactStateCacheAccess.java:78)
 at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:31)
 at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:86)
 at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
 at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
 at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
 at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
 at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
 at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
 at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
 at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166)
 at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
 at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
 at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
 at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
 at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
 at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
 at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
 at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
 at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
 at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
 at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
 at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
 at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
 at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
 at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
 at org.gradle.launcher.Main.doAction(Main.java:46)
 at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
 at org.gradle.launcher.Main.main(Main.java:37)
 at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
 at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
 at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: : taskdef A class needed by class org.jacoco.ant.ReportTask cannot be found: org/jacoco/core/analysis/ICoverageVisitor
 using the classloader AntClassLoader[E:\development\sources\gradle-issues\jacoco-lib\org.jacoco.ant-0.6.3.201306030806.jar]
 at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:612)
 at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:237)
 at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
 at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
 at org.gradle.api.internal.project.ant.BasicAntBuilder.nodeCompleted(BasicAntBuilder.java:71)
 at org.gradle.api.internal.project.ant.BasicAntBuilder.doInvokeMethod(BasicAntBuilder.java:86)
 at org.gradle.api.internal.project.DefaultAntBuilder.super$3$invokeMethod(DefaultAntBuilder.groovy)
 at org.gradle.api.internal.project.DefaultAntBuilder.invokeMethod(DefaultAntBuilder.groovy:37)
 at org.gradle.testing.jacoco.tasks.JacocoReport.generate(JacocoReport.groovy:76)
 at org.gradle.util.JavaMethod.invoke(JavaMethod.java:62)
 at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:219)
 at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:212)
 at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:201)
 at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:527)
 at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:510)
 at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
 at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
 ... 49 more
Caused by: java.lang.NoClassDefFoundError: org/jacoco/core/analysis/ICoverageVisitor
 at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:579)
 ... 65 more
Caused by: java.lang.ClassNotFoundException: org.jacoco.core.analysis.ICoverageVisitor
 at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1366)
 at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1315)
 at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1068)
 ... 66 more

(Peter Niederwieser) #8

The easiest solution is to resolve the Jacoco dependencies from Maven Central (or a proxy thereof). Otherwise you’ll need to look at the output of ‘gradle dependencies’ and put the exact Jacoco dependencies that you find there into your ‘jacoco-lib’ directory (named ‘arifactName-version.extension’). If these dependencies have transitive dependencies (which you can check on http://search.maven.org), you’ll have to add those as well.


(dhruv.jrt) #9

I think currently it will difficult to make jacocoTestReport work without Maven Central. The classloading logic seems to be a part of the plugin code itself (not very sure though!). gradle dependencies will not work because where will gradle come to know of the dependencies if you don’t have a definition of the dependencies like a pom file. Will look into the plugin code later if I find time.


(Peter Niederwieser) #10

I think currently it will difficult to make jacocoTestReport work without Maven Central.

It’s not as simple as when using a Maven repository, but I know that some people have been successful with it.

gradle dependencies will not work because where will gradle come to know of the dependencies if you don’t have a definition of the dependencies like a pom file.

I think you should see the Jacoco dependencies configured by the plugin (even if they can’t be resolved). Of course you can also look at the plugin code on GitHub.


(dhruv.jrt) #11

Finally got it working, the task used classpath as getJacocoClasspath().asPath.

jacocoTestReport {
 File jacocoLibDir = file("jacoco-lib")
 jacocoClasspath = files { jacocoLibDir.listFiles() }
}

Thanks!