group 'io.opentelemetry.example'
version '1.0-SNAPSHOT'

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
    maven {
      name = "sonatype"
      url = uri("https://central.sonatype.com/repository/maven-snapshots/")
    }
  }
  dependencies {
    classpath "com.diffplug.spotless:spotless-plugin-gradle:7.2.0"
    classpath "com.gradleup.shadow:shadow-gradle-plugin:8.3.8"
    classpath "io.opentelemetry.instrumentation:gradle-plugins:2.19.0-alpha-SNAPSHOT"
  }
}

subprojects {
  version = rootProject.version

  apply plugin: "java"
  apply plugin: "com.diffplug.spotless"

  ext {
    versions = [
      // this line is managed by .github/scripts/update-sdk-version.sh
      opentelemetrySdk           : "1.52.0",

      // these lines are managed by .github/scripts/update-version.sh
      opentelemetryJavaagent     : "2.19.0-SNAPSHOT",
      opentelemetryJavaagentAlpha: "2.19.0-alpha-SNAPSHOT",

      autoservice                : "1.1.1"
    ]

    deps = [
      autoservice: [
        "com.google.auto.service:auto-service:${versions.autoservice}",
        "com.google.auto.service:auto-service-annotations:${versions.autoservice}",
      ]
    ]
  }

  repositories {
    mavenCentral()
    maven {
      name = "sonatype"
      url = uri("https://central.sonatype.com/repository/maven-snapshots/")
    }
  }

  spotless {
    java {
      googleJavaFormat()
      licenseHeaderFile(rootProject.file("../../buildscripts/spotless.license.java"), "(package|import|public)")
      target("src/**/*.java")
    }
  }

  dependencies {
    implementation(platform("io.opentelemetry:opentelemetry-bom:${versions.opentelemetrySdk}"))

    // these serve as a test of the instrumentation boms
    implementation(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:${versions.opentelemetryJavaagent}"))
    implementation(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${versions.opentelemetryJavaagentAlpha}"))

    testImplementation("org.mockito:mockito-core:5.18.0")

    testImplementation(enforcedPlatform("org.junit:junit-bom:5.13.3"))
    testImplementation("org.junit.jupiter:junit-jupiter-api")
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
    testRuntimeOnly("org.junit.platform:junit-platform-launcher")
  }

  tasks {
    test {
      useJUnitPlatform()
    }

    compileJava {
      options.release.set(8)
    }
  }
}
