group = 'io.opentelemetry.javaagent'

apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/publish.gradle"

// TODO this is not the desired state, only reflects current reality
minimumBranchCoverage = 0
minimumInstructionCoverage = 0

configurations {
  // classpath used by the instrumentation muzzle plugin
  instrumentationMuzzle {
    canBeConsumed = true
    canBeResolved = false
    extendsFrom implementation
  }
}

dependencies {
  implementation project(':javaagent-bootstrap')
  implementation project(':javaagent-spi')
  implementation project(':javaagent-api')
  implementation project(':instrumentation-api')

  implementation deps.opentelemetryApi
  implementation deps.opentelemetryApiMetrics
  implementation deps.opentelemetryContext
  implementation deps.opentelemetrySdk
  implementation deps.opentelemetrySdkAutoconfigure
  implementation deps.opentelemetrySdkMetrics
  implementation(deps.opentelemetryKotlin) {
    // opentelemetry-extension-kotlin classes are injected into user classpath
    // where kotlin core libraries are already present
    exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-common'
    exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-coroutines-core'
  }
  implementation deps.opentelemetryExtAws
  implementation deps.opentelemetryTraceProps
  implementation(deps.opentelemetryResources) {
    // exclude sdk-common to avoid bumping guava version
    exclude group: 'io.opentelemetry', module: 'opentelemetry-sdk-common'
  }

  implementation deps.opentelemetryJaeger
  implementation deps.opentelemetryLogging
  implementation deps.opentelemetryOtlp
  implementation deps.opentelemetryOtlpMetrics

  implementation deps.opentelemetryPrometheus
  implementation deps.prometheus

  implementation deps.opentelemetryZipkin

  implementation group: 'com.blogspot.mydailyjava', name: 'weak-lock-free', version: '0.15'
  implementation deps.bytebuddy
  implementation deps.bytebuddyagent
  annotationProcessor deps.autoservice
  implementation deps.autoservice
  implementation deps.slf4j

  implementation group: 'io.grpc', name: 'grpc-netty', version: '1.34.1'

  testImplementation project(':testing-common')
  testImplementation deps.assertj
  testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.6.0'

  instrumentationMuzzle sourceSets.main.output
}

test {
  filter {
    excludeTestsMatching 'HelperInjectionTest'
  }
}
// Needs a fresh classloader.
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/919
test.finalizedBy(tasks.register('testHelperInjection', Test) {
  filter {
    includeTestsMatching 'HelperInjectionTest'
  }
})
