0

I have configured a simple bndtools project with one bundle project. I am using 'biz.aQute.bnd.workspace' bnd gradle plugin to build the project. The build is working fine.

Now I want to add jacoco gradle plugin to get the coverage report and I always get following error.

* What went wrong:
Could not resolve all dependencies for configuration 
':com.example.api:jacocoAgent'.
> Cannot resolve external dependency org.jacoco:org.jacoco.agent:0.7.8 
because no repositories are defined.
Required by:
  project :com.example.api

My Settings.gradle file

buildscript {
 repositories {
maven {
  url 'https://bndtools.ci.cloudbees.com/job/bnd.master/lastSuccessfulBuild/artifact/dist/bundles'
}
mavenCentral()
}
dependencies {
     classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:+', 'org.jacoco:org.jacoco.agent:0.7.8'

}
}
apply plugin: 'biz.aQute.bnd.workspace'

My build.gradle file is as below

subprojects {

apply plugin: 'jacoco'
}
Prafull
  • 73
  • 4

2 Answers2

0

I'm not sure what the problem with your setup is, but this is what is working for me, hope it helps:

In the project folder ("com.example.api" in your case) I added a build.gradle file like this

apply plugin: "jacoco"

repositories {
    mavenCentral()
}

jacoco {
    toolVersion = "0.7.1.201405082137"
}

The fine-tuning is done using a "sonar-project.properties" file next to build.gradle, something like this:

sonar.projectKey=com.example.api
sonar.projectName=...
sonar.projectVersion=...

# Comma-separated paths to directories with sources (required)
sonar.sources=com.example.api/src

sonar.tests=com.example.api/test

sonar.junit.reportsPath=com.example.api/generated/reports/tests/xml

# Language
sonar.language=java

# Encoding of the source files
sonar.sourceEncoding=UTF-8

sonar.binaries=com.example.api/bin
sonar.java.coveragePlugin=jacoco
sonar.jacoco.reportPath=com.example.api/generated/jacoco/test.exec

#http://docs.sonarqube.org/display/PLUG/Java+Plugin+and+Bytecode
sonar.java.binaries=com.example.api/bin,com.example.api/bin_test
sonar.java.libraries=/somepath/cnf/nonosgi-repo/lombok/lombok-1.16.10.jar

Hope that helps!

evandor
  • 799
  • 1
  • 10
  • 23
0

Just remove that jacoco agent (org.jacoco:org.jacoco.agent:0.7.8) from the classpath.

My development environment is:

  • gradle version: 4.10.2
  • plugin: biz.aQute.bnd:biz.aQute.bnd.gradle:4.0.0