From b8ff9bcd308cfb6a2dd56d2b51bd82ed67e58c3d Mon Sep 17 00:00:00 2001 From: Rees Pozzi Date: Fri, 8 Nov 2024 09:56:34 +0000 Subject: [PATCH] Allow Java21 on yarn builds (#1280) --- src/uk/gov/hmcts/contino/YarnBuilder.groovy | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/uk/gov/hmcts/contino/YarnBuilder.groovy b/src/uk/gov/hmcts/contino/YarnBuilder.groovy index 1a8aa5f16c..12a3caead6 100644 --- a/src/uk/gov/hmcts/contino/YarnBuilder.groovy +++ b/src/uk/gov/hmcts/contino/YarnBuilder.groovy @@ -395,6 +395,17 @@ EOF @Override def setupToolVersion() { super.setupToolVersion() + // Java required on nodejs pipeline, if data import only available as java job, but project itself is nodejs + def statusCodeJava21 = steps.sh(script: """ + find . -name "build.gradle" -exec grep -l "JavaLanguageVersion.of(21)" {} + > /dev/null + """, returnStatus: true) + if (statusCodeJava21 == 0) { + def javaHomeLocation = steps.sh(script: 'ls -d /usr/lib/jvm/temurin-21-jdk-*', returnStdout: true, label: 'Detect Java location').trim() + steps.env.JAVA_HOME = javaHomeLocation + steps.env.PATH = "${steps.env.JAVA_HOME}/bin:${steps.env.PATH}" + } + + localSteps.sh "java -version" nagAboutOldNodeJSVersions() }