plugins {
  id "java"
  id "com.google.cloud.tools.jib" version "3.1.4"
  id "com.diffplug.spotless" version "6.1.2"
}

group = "io.opentelemetry"
version = "0.0.1-SNAPSHOT"

repositories {
  mavenCentral()
  // this is only needed for the working against unreleased otel-java snapshots
  maven {
    url "https://oss.sonatype.org/content/repositories/snapshots"
    content {
      includeGroup "io.opentelemetry"
    }
  }
}

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

dependencies {
  implementation platform("io.grpc:grpc-bom:1.33.1")
  implementation platform("io.opentelemetry:opentelemetry-bom:1.0.0")
  implementation platform("io.opentelemetry:opentelemetry-bom-alpha:1.0.0-alpha")
  implementation platform("org.apache.logging.log4j:log4j-bom:2.16.0")

  implementation "io.grpc:grpc-netty-shaded"
  implementation "io.grpc:grpc-protobuf"
  implementation "io.grpc:grpc-stub"
  implementation "io.opentelemetry.proto:opentelemetry-proto:0.11.0-alpha"
  implementation "io.opentelemetry:opentelemetry-extension-annotations"
  implementation "org.apache.logging.log4j:log4j-core"

  runtimeOnly("org.apache.logging.log4j:log4j-slf4j-impl")
}

compileJava {
  options.release = 8
}

def targetJDK = project.hasProperty("targetJDK") ? project.targetJDK : 11

def tag = findProperty("tag") ?: new Date().format("yyyyMMdd.HHmmSS")

jib {
  from.image = "openjdk:$targetJDK"
  to.image = "ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-grpc:jdk$targetJDK-$tag"
}
