plugins {
  id "org.springframework.boot" version "2.3.2.RELEASE"
  id "io.spring.dependency-management" version "1.0.9.RELEASE"
  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.opentelemetry:opentelemetry-bom:1.0.0")

  implementation "org.springframework.boot:spring-boot-starter-web"
  implementation "io.opentelemetry:opentelemetry-extension-annotations"
  implementation "io.opentelemetry:opentelemetry-api"
}

compileJava {
  options.release.set(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-spring-boot:jdk$targetJDK-$tag"
  container.ports = ["8080"]
}