From 64ca9482a53af7e4f8fd2fa5551b8f50dcda7755 Mon Sep 17 00:00:00 2001 From: Roberto Tyley <52038+rtyley@users.noreply.github.com> Date: Wed, 18 Sep 2024 16:36:57 +0100 Subject: [PATCH 1/3] Upgrade to Java 11 https://github.com/guardian/flexible-content/pull/4392/files/47b4f2d0fa866948794f8ea64af9a72410d01847..eee9afec3b41e86a1eedf437633d10c656d5f1da#r1317092876 --- .github/workflows/ci.yml | 4 ++-- .java-version | 2 +- .tool-versions | 1 + build.sbt | 11 +++++------ project/build.properties | 2 +- project/plugins.sbt | 18 +++++++++++++++--- riff-raff.yaml | 2 +- 7 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 .tool-versions diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ff09149ca..8876778ba2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,9 +56,9 @@ jobs: sudo apt-get -y install graphicsmagick-imagemagick-compat sudo apt-get -y install exiftool - name: Setup Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: - java-version: '8' + java-version: '11' distribution: 'corretto' cache: 'sbt' - name: SBT diff --git a/.java-version b/.java-version index 6259340971..b4de394767 100644 --- a/.java-version +++ b/.java-version @@ -1 +1 @@ -1.8 +11 diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000000..b60a0e5cfc --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +java corretto-11.0.24.8.1 diff --git a/build.sbt b/build.sbt index 93050a2f7b..4edb2f8fc4 100644 --- a/build.sbt +++ b/build.sbt @@ -15,11 +15,11 @@ import com.typesafe.sbt.packager.debian.JDebPackaging ThisBuild / packageOptions += FixedTimestamp(Package.keepTimestamps) val commonSettings = Seq( - scalaVersion := "2.12.15", + scalaVersion := "2.12.20", description := "grid", organization := "com.gu", version := "0.1", - scalacOptions ++= Seq("-feature", "-deprecation", "-language:higherKinds", "-Xfatal-warnings"), + scalacOptions ++= Seq("-feature", "-deprecation", "-language:higherKinds", "-Xfatal-warnings", "-release:11"), // The Java SDK uses CBOR protocol // We use localstack in TEST. Kinesis in localstack uses kinesislite which requires CBOR to be disabled @@ -220,7 +220,7 @@ def playProject(projectName: String, port: Int, path: Option[String] = None): Pr .dependsOn(restLib) .settings(commonSettings ++ buildInfo ++ Seq( playDefaultPort := port, - debianPackageDependencies := Seq("openjdk-8-jre-headless"), + debianPackageDependencies := Seq("java11-runtime-headless"), Linux / maintainer := "Guardian Developers ", Linux / packageSummary := description.value, packageDescription := description.value, @@ -244,9 +244,8 @@ def playProject(projectName: String, port: Int, path: Option[String] = None): Pr "-Dpidfile.path=/dev/null", s"-Dconfig.file=/usr/share/$projectName/conf/application.conf", s"-Dlogger.file=/usr/share/$projectName/conf/logback.xml", - "-J-XX:+PrintGCDetails", - "-J-XX:+PrintGCDateStamps", - s"-J-Xloggc:/var/log/$projectName/gc.log", + "-J-Xlog:gc*", + s"-J-Xlog:gc:/var/log/$projectName/gc.log", "-J-XX:+UseGCLogFileRotation", "-J-XX:NumberOfGCLogFiles=5", "-J-XX:GCLogFileSize=2M" diff --git a/project/build.properties b/project/build.properties index c8fcab543a..ee4c672cd0 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.6.2 +sbt.version=1.10.1 diff --git a/project/plugins.sbt b/project/plugins.sbt index 387b3f1422..6e28fff341 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -14,6 +14,18 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.4") addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.2") -// needed by Snyk to accurately report vulnerabilities -// https://docs.snyk.io/scan-application-code/snyk-open-source/snyk-open-source-supported-languages-and-package-managers/snyk-for-scala -addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.10.0-RC1") +/* + Without setting VersionScheme.Always here on `scala-xml`, sbt 1.8.0 will raise fatal 'version conflict' errors when + used with sbt plugins like `sbt-native-packager`, which currently use sort-of-incompatible versions of the `scala-xml` + library. sbt 1.8.0 has upgraded to Scala 2.12.17, which has itself upgraded to `scala-xml` 2.1.0 + (see https://github.com/sbt/sbt/releases/tag/v1.8.0), but `sbt-native-packager` is currently using `scala-xml` 1.1.1, + and the `scala-xml` library declares that it uses specifically 'early-semver' version compatibility (see + https://www.scala-lang.org/blog/2021/02/16/preventing-version-conflicts-with-versionscheme.html#versionscheme-librarydependencyschemes-and-sbt-150 ), + meaning that for version x.y.z, `x` & `y` *must match exactly* for versions to be considered compatible by sbt. + By setting VersionScheme.Always here on `scala-xml`, we're overriding its declared version-compatability scheme, + choosing to tolerate the risk of binary incompatibility. We consider this to be safe because when set under + `projects/` (ie *not* in `build.sbt` itself) it only affects the compilation of build.sbt, not of the application + build itself. Once the build has succeeded, there is no further risk (ie of a runtime exception due to clashing + versions of `scala-xml`). + */ +libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always diff --git a/riff-raff.yaml b/riff-raff.yaml index b80a12db4b..56adb0526c 100644 --- a/riff-raff.yaml +++ b/riff-raff.yaml @@ -89,7 +89,7 @@ deployments: AmiId: BuiltBy: amigo AmigoStage: PROD - Recipe: editorial-tools-focal-java8-ARM-WITH-cdk-base + Recipe: editorial-tools-focal-java11-ARM-WITH-cdk-base ImagingAmiId: BuiltBy: amigo AmigoStage: PROD From d2ec798aa89fc7a0b73efcfae9c9271d9b172e14 Mon Sep 17 00:00:00 2001 From: Roberto Tyley <52038+rtyley@users.noreply.github.com> Date: Fri, 20 Sep 2024 16:17:47 +0100 Subject: [PATCH 2/3] Remove additional obsolete GC logging settings --- build.sbt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index 4edb2f8fc4..2063bd41bc 100644 --- a/build.sbt +++ b/build.sbt @@ -245,10 +245,7 @@ def playProject(projectName: String, port: Int, path: Option[String] = None): Pr s"-Dconfig.file=/usr/share/$projectName/conf/application.conf", s"-Dlogger.file=/usr/share/$projectName/conf/logback.xml", "-J-Xlog:gc*", - s"-J-Xlog:gc:/var/log/$projectName/gc.log", - "-J-XX:+UseGCLogFileRotation", - "-J-XX:NumberOfGCLogFiles=5", - "-J-XX:GCLogFileSize=2M" + s"-J-Xlog:gc:/var/log/$projectName/gc.log" ) )) //Add the BBC library dependency if defined From 264b2bd769000e8d74766722f4b6aeecb1abd038 Mon Sep 17 00:00:00 2001 From: Roberto Tyley <52038+rtyley@users.noreply.github.com> Date: Fri, 20 Sep 2024 17:00:15 +0100 Subject: [PATCH 3/3] Use new grid-imaging-java11-ARM AMIgo image The two services (`image-loader` & `cropper`) failed to deploy - although they use Java (and so now need Java 11) they _don't_ use the `editorial-tools-focal-javaX-ARM-WITH-cdk-base` Amigo image - they use `grid-imaging-ARM`: https://github.com/guardian/grid/pull/4329#issuecomment-2364046451 ...so I've created a new https://amigo.gutools.co.uk/recipes/grid-imaging-java11-ARM Amigo recipe. --- riff-raff.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/riff-raff.yaml b/riff-raff.yaml index 56adb0526c..35f28b4532 100644 --- a/riff-raff.yaml +++ b/riff-raff.yaml @@ -93,7 +93,7 @@ deployments: ImagingAmiId: BuiltBy: amigo AmigoStage: PROD - Recipe: grid-imaging-ARM + Recipe: grid-imaging-java11-ARM ImgOpsAmiId: BuiltBy: amigo AmigoStage: PROD