Migrate jacoco.gradle to plugin
ADD
buildSrc/src/main/kotlin/otel.jacoco-conventions.gradle.kts
+plugins {
+ jacoco
+}
+
+jacoco {
+ toolVersion = "0.8.6"
+}
+
+tasks {
+ named<JacocoReport>("jacocoTestReport") {
+ dependsOn("test")
+
+ reports {
+ xml.isEnabled = true
+ csv.isEnabled = false
+ html.destination = file("${buildDir}/reports/jacoco/")
+ }
+ }
+}

MODIFY
buildSrc/src/main/kotlin/otel.java-conventions.gradle.kts
buildSrc/src/main/kotlin/otel.java-conventions.gradle.kts
@@ -27,17 +27,6 @@ afterEvaluate {
// Version to use to compile code and run tests.
val DEFAULT_JAVA_VERSION = JavaVersion.VERSION_11
-val applyCodeCoverage = !project.path.run {
- startsWith(":smoke-tests") ||
- startsWith(":benchmark") ||
- startsWith(":instrumentation") ||
- startsWith(":testing-common")
-}
-
-if (applyCodeCoverage) {
- apply(from = "${rootDir}/gradle/jacoco.gradle")
-}
-
java {
toolchain {
languageVersion.set(otelJava.minJavaVersionSupported.map { JavaLanguageVersion.of(Math.max(it.majorVersion.toInt(), DEFAULT_JAVA_VERSION.majorVersion.toInt())) })

MODIFY
buildSrc/src/main/kotlin/otel.library-instrumentation.gradle.kts
buildSrc/src/main/kotlin/otel.library-instrumentation.gradle.kts
plugins {
id("otel.java-conventions")
+ id("otel.jacoco-conventions")
id("otel.publish-conventions")
id("otel.instrumentation-conventions")
}

DELETE
gradle/jacoco.gradle
-apply plugin: "jacoco"
-
-jacoco {
- toolVersion = "0.8.6"
-}
-
-tasks.named('jacocoTestReport').configure {
- dependsOn('test')
- reports {
- xml.enabled true
- csv.enabled false
- html.destination file("${buildDir}/reports/jacoco/")
- }
-}

MODIFY
instrumentation-api/instrumentation-api.gradle
instrumentation-api/instrumentation-api.gradle
@@ -5,6 +5,7 @@ plugins {
group = 'io.opentelemetry.instrumentation'
apply plugin: "otel.java-conventions"
+apply plugin: "otel.jacoco-conventions"
apply plugin: "otel.publish-conventions"
def jflexTargetDir = file"${project.buildDir}/generated/jflex/sql"

MODIFY
javaagent-api/javaagent-api.gradle
javaagent-api/javaagent-api.gradle
group = 'io.opentelemetry.javaagent'
apply plugin: "otel.java-conventions"
+apply plugin: "otel.jacoco-conventions"
apply plugin: "otel.publish-conventions"
dependencies {

Migrate jacoco.gradle to plugin (#3330)