apply from: "$rootDir/gradle/instrumentation.gradle"

muzzle {
  pass {
    group = "org.apache.kafka"
    module = "kafka-clients"
    versions = "[0.11.0.0,)"
    assertInverse = true
  }
}

dependencies {
  library group: 'org.apache.kafka', name: 'kafka-clients', version: '0.11.0.0'

  testLibrary group: 'org.springframework.kafka', name: 'spring-kafka', version: '1.3.3.RELEASE'
  testLibrary group: 'org.springframework.kafka', name: 'spring-kafka-test', version: '1.3.3.RELEASE'
  testImplementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.2.3'
  testLibrary group: 'org.assertj', name: 'assertj-core', version: '2.9.+'
  testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.6.0'

  // Include latest version of kafka itself along with latest version of client libs.
  // This seems to help with jar compatibility hell.
  latestDepTestLibrary group: 'org.apache.kafka', name: 'kafka_2.11', version: '2.3.+'
  // (Pinning to 2.3.x: 2.4.0 introduces an error when executing compileLatestDepTestGroovy)
  //  Caused by: java.lang.NoClassDefFoundError: org.I0Itec.zkclient.ZkClient
  latestDepTestLibrary group: 'org.apache.kafka', name: 'kafka-clients', version: '2.3.+'
  latestDepTestLibrary group: 'org.springframework.kafka', name: 'spring-kafka', version: '2.2.+'
  latestDepTestLibrary group: 'org.springframework.kafka', name: 'spring-kafka-test', version: '2.2.+'
  latestDepTestLibrary group: 'org.assertj', name: 'assertj-core', version: '3.+'
}

tasks.withType(Test) {
  // TODO run tests both with and without experimental span attributes
  jvmArgs "-Dotel.instrumentation.kafka.experimental-span-attributes=true"
}
test {
  filter {
    excludeTestsMatching 'KafkaClientPropagationDisabledTest'
  }
}
test.finalizedBy(tasks.register("testPropagationDisabled", Test) {
  filter {
    includeTestsMatching 'KafkaClientPropagationDisabledTest'
  }
  jvmArgs "-Dotel.instrumentation.kafka.client-propagation=false"
})
