def groovyVer = "2.5.11"
def spockGroovyVer = groovyVer.replaceAll(/\.\d+$/, '')

// this is only needed for the working against unreleased otel-java snapshots
configurations.all {
  resolutionStrategy.cacheChangingModulesFor 12, 'hours'
}

ext {
  versions = [
    opentelemetry     : '0.17.0',
    opentelemetryAlpha: "0.17.0-alpha",

    slf4j             : "1.7.30",
    guava             : "30.1-jre",

    spock             : "1.3-groovy-$spockGroovyVer",
    groovy            : groovyVer,
    logback           : "1.2.3",
    bytebuddy         : "1.10.18", // Also explicitly specified in buildSrc
    scala             : "2.11.12",  // Last version to support Java 7 (2.12+ require Java 8+)
    kotlin            : "1.4.0",
    coroutines        : "1.3.0",
    springboot        : "2.3.1.RELEASE",
    junit5            : "5.7.1",
    checkerFramework  : "3.6.1",
    errorprone        : "2.4.0",
    nullaway          : "0.8.0",
    autoValue         : "1.7.4",
    systemLambda      : "1.1.0",
    prometheus        : "0.9.0",
    assertj           : '3.19.0'
  ]

  deps = [
    // OpenTelemetry
    opentelemetryApi             : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-api', version: versions.opentelemetry),
    opentelemetryApiMetrics      : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-api-metrics', version: versions.opentelemetryAlpha),
    opentelemetryExtAnnotations  : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-extension-annotations', version: versions.opentelemetry),
    opentelemetryExtAws          : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-extension-aws', version: versions.opentelemetry),
    opentelemetryContext         : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-context', version: versions.opentelemetry),
    opentelemetryKotlin          : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-extension-kotlin', version: versions.opentelemetry),
    opentelemetryLogging         : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporter-logging', version: versions.opentelemetry),
    opentelemetryTraceProps      : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-extension-trace-propagators', version: versions.opentelemetry),
    opentelemetrySdk             : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-sdk', version: versions.opentelemetry),
    opentelemetrySdkAutoconfigure: dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-sdk-extension-autoconfigure', version: versions.opentelemetryAlpha),
    opentelemetrySdkMetrics      : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-sdk-metrics', version: versions.opentelemetryAlpha),
    opentelemetryJaeger          : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporter-jaeger', version: versions.opentelemetry),
    opentelemetryOtlp            : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporter-otlp', version: versions.opentelemetry),
    opentelemetryOtlpMetrics     : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporter-otlp-metrics', version: versions.opentelemetryAlpha),
    opentelemetryZipkin          : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporter-zipkin', version: versions.opentelemetry),
    opentelemetryPrometheus      : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporter-prometheus', version: versions.opentelemetryAlpha),
    opentelemetryLogging         : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporter-logging', version: versions.opentelemetry),
    opentelemetryProto           : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-proto', version: versions.opentelemetry),
    opentelemetryResources       : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-sdk-extension-resources', version: versions.opentelemetry),
    opentelemetrySdkTesting      : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-sdk-testing', version: versions.opentelemetry),
    opentelemetrySemConv         : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-semconv', version: versions.opentelemetryAlpha),

    // General
    slf4j                        : "org.slf4j:slf4j-api:${versions.slf4j}",
    guava                        : "com.google.guava:guava:$versions.guava",
    bytebuddy                    : dependencies.create(group: 'net.bytebuddy', name: 'byte-buddy', version: "${versions.bytebuddy}"),
    bytebuddyagent               : dependencies.create(group: 'net.bytebuddy', name: 'byte-buddy-agent', version: "${versions.bytebuddy}"),
    autoservice                  : [
      dependencies.create(group: 'com.google.auto.service', name: 'auto-service', version: '1.0-rc7'),
      dependencies.create(group: 'com.google.auto', name: 'auto-common', version: '0.8'),
    ],
    autoValueAnnotations         : "com.google.auto.value:auto-value-annotations:${versions.autoValue}",
    // annotation processor
    autoValue                    : "com.google.auto.value:auto-value:${versions.autoValue}",
    prometheus                   : [
      dependencies.create(group: 'io.prometheus', name: 'simpleclient', version: "${versions.prometheus}"),
      dependencies.create(group: 'io.prometheus', name: 'simpleclient_httpserver', version: "${versions.prometheus}"),
    ],

    // Testing

    spock                        : [
      dependencies.create("org.spockframework:spock-core:${versions.spock}", {
        exclude group: 'org.codehaus.groovy', module: 'groovy-all'
      }),
      // Used by Spock for mocking:
      dependencies.create(group: 'org.objenesis', name: 'objenesis', version: '3.1')
    ],
    groovy                       : "org.codehaus.groovy:groovy-all:${versions.groovy}",
    systemLambda                 : "com.github.stefanbirkner:system-lambda:${versions.systemLambda}",
    testcontainers               : "org.testcontainers:testcontainers:1.15.1",
    testLogging                  : [
      dependencies.create(group: 'ch.qos.logback', name: 'logback-classic', version: versions.logback),
      dependencies.create(group: 'org.slf4j', name: 'log4j-over-slf4j', version: versions.slf4j),
      dependencies.create(group: 'org.slf4j', name: 'jcl-over-slf4j', version: versions.slf4j),
      dependencies.create(group: 'org.slf4j', name: 'jul-to-slf4j', version: versions.slf4j),
    ],
    scala                        : dependencies.create(group: 'org.scala-lang', name: 'scala-library', version: "${versions.scala}"),
    kotlin                       : dependencies.create(group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: "${versions.kotlin}"),
    coroutines                   : dependencies.create(group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: "${versions.coroutines}"),
    junitApi                     : "org.junit.jupiter:junit-jupiter-api:${versions.junit5}",
    assertj                      : "org.assertj:assertj-core:${versions.assertj}",
  ]
}
