From e7bbb0235a667167cbe12765293afa42976ef17a Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 16 Nov 2025 12:40:19 -0800 Subject: [PATCH] Update play gradle plugin --- .../play/app/controllers/HomeController.scala | 2 +- smoke-tests/images/play/build.gradle.kts | 41 ++++++++----------- smoke-tests/images/play/conf/application.conf | 2 +- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/smoke-tests/images/play/app/controllers/HomeController.scala b/smoke-tests/images/play/app/controllers/HomeController.scala index bd2f9859b6df..7cbab34bc194 100644 --- a/smoke-tests/images/play/app/controllers/HomeController.scala +++ b/smoke-tests/images/play/app/controllers/HomeController.scala @@ -16,7 +16,7 @@ package controllers -import javax.inject.Inject +import jakarta.inject.Inject import play.api.mvc._ diff --git a/smoke-tests/images/play/build.gradle.kts b/smoke-tests/images/play/build.gradle.kts index 2b10b0f4b029..6cc910f4bd94 100644 --- a/smoke-tests/images/play/build.gradle.kts +++ b/smoke-tests/images/play/build.gradle.kts @@ -1,3 +1,5 @@ +import org.gradle.jvm.toolchain.JavaLanguageVersion +import play.gradle.Language import java.time.LocalDateTime import java.time.format.DateTimeFormatter @@ -6,44 +8,33 @@ plugins { id("otel.spotless-conventions") id("com.google.cloud.tools.jib") - // TODO (trask) this plugin doesn't support Play 2.9+, see https://github.com/gradle/playframework/issues/185 - // once play 3.1 is released, we can update to https://github.com/orgs/playframework/discussions/12338 - id("org.gradle.playframework") version "0.16.0" + id("org.playframework.play") version "3.1.0-M4" } -val playVer = "2.8.22" -val scalaVer = "2.12" - play { - platform { - playVersion.set(playVer) - scalaVersion.set(scalaVer) - javaVersion.set(JavaVersion.VERSION_1_8) - } - injectedRoutesGenerator.set(true) + lang.set(Language.SCALA) } dependencies { - implementation("com.typesafe.play:play-guice_$scalaVer:$playVer") - // Guice 5.1 is needed for Java 17 support on Play 2.8, see https://github.com/playframework/playframework/releases/tag/2.8.15 - // TODO (trask) remove these version overrides after updating to Play 2.9 - implementation("com.google.inject:guice:5.1.0") - implementation("com.google.inject.extensions:guice-assistedinject:5.1.0") - implementation("com.typesafe.play:play-logback_$scalaVer:$playVer") - implementation("com.typesafe.play:filters-helpers_$scalaVer:$playVer") + val playVersion = "3.1.0-M4" + val scalaVersion = "2.13" + + implementation("org.playframework:play-guice_$scalaVersion:$playVersion") + implementation("org.playframework:play-logback_$scalaVersion:$playVersion") + implementation("org.playframework:play-filters-helpers_$scalaVersion:$playVersion") + runtimeOnly("org.playframework:play-server_$scalaVersion:$playVersion") + runtimeOnly("org.playframework:play-pekko-http-server_$scalaVersion:$playVersion") + runtimeOnly("org.apache.pekko:pekko-http_$scalaVersion:1.3.0") } -val targetJDK = project.findProperty("targetJDK") ?: "11" +val targetJDK = (project.findProperty("targetJDK") as String?) ?: "17" +val javaLanguageVersion = targetJDK.toIntOrNull() ?: 17 val tag = findProperty("tag") ?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now()) java { - // this is needed to avoid jib failing with - // "Your project is using Java 17 but the base image is for Java 8" - // (it seems the jib plugins does not understand toolchains yet) - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + toolchain.languageVersion.set(JavaLanguageVersion.of(javaLanguageVersion)) } val repo = System.getenv("GITHUB_REPOSITORY") ?: "open-telemetry/opentelemetry-java-instrumentation" diff --git a/smoke-tests/images/play/conf/application.conf b/smoke-tests/images/play/conf/application.conf index 0ab7303cedc5..f68c95735b4a 100644 --- a/smoke-tests/images/play/conf/application.conf +++ b/smoke-tests/images/play/conf/application.conf @@ -1,3 +1,3 @@ # https://www.playframework.com/documentation/latest/Configuration -play.http.secret.key=agentbenchmarktest0xCAFEDEAD +play.http.secret.key=0123456789abcdeffedcba9876543210 http.port=8080