plugins {
  id "org.gradle.playframework" version "0.12"
  id "com.google.cloud.tools.jib" version "3.1.4"
  id "com.diffplug.spotless" version "6.1.2"
}

ext {
  playVersion = "2.6.20"
  scalaVersion = System.getProperty("scala.binary.version", /* default = */ "2.12")
}

play {
  platform {
    playVersion = project.ext.playVersion
    scalaVersion = project.ext.scalaVersion
    javaVersion = JavaVersion.VERSION_1_8
  }
  injectedRoutesGenerator = true
}

repositories {
  mavenLocal()
  mavenCentral()
  maven {
    name "lightbend-maven-releases"
    url "https://repo.lightbend.com/lightbend/maven-release"
  }
}

description = "Play Integration Tests."

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

dependencies {
  implementation "com.typesafe.play:play-guice_$scalaVersion:$playVersion"
  implementation "com.typesafe.play:play-logback_$scalaVersion:$playVersion"
  implementation "com.typesafe.play:filters-helpers_$scalaVersion:$playVersion"
}

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-play:jdk$targetJDK-$tag"
  container.mainClass = "play.core.server.ProdServerStart"
}