Skip to content

Commit

Permalink
CCD-4600 - Updated to Java 17, ApplicationInsights 3.x (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
ladamson-hmcts authored Aug 31, 2023
1 parent 52651c9 commit d39d09a
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 101 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/dependency-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'zulu'
java-version: 17
distribution: 'temurin'
- name: Run dependencyCheck
run: ./gradlew dependencyCheckAggregate
continue-on-error: true
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.gradle
/build/
!gradle/wrapper/gradle-wrapper.jar
applicationinsights-agent-*.jar
*.log

### STS ###
.apt_generated
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
ARG PLATFORM=""

FROM hmctspublic.azurecr.io/base/java${PLATFORM}:11-distroless
FROM hmctspublic.azurecr.io/base/java${PLATFORM}:17-distroless
USER hmcts

ENV APPLICATION_TOTAL_MEMORY 128M
ENV APPLICATION_SIZE_ON_DISK_IN_MB 41
ENV JAVA_OPTS ""

COPY lib/AI-Agent.xml /opt/app/
COPY lib/applicationinsights.json /opt/app
COPY build/libs/ccd-test-stubs-service.jar /opt/app/
COPY wiremock/mappings /opt/app/wiremock/mappings

Expand Down
4 changes: 2 additions & 2 deletions acb.tpl.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 1.0-preview-1
steps:
- id: pull-base-image-amd64
cmd: docker pull --platform linux/amd64 hmctspublic.azurecr.io/base/java:11-distroless && docker tag hmctspublic.azurecr.io/base/java:11-distroless hmctspublic.azurecr.io/base/java/linux/amd64:11-distroless
cmd: docker pull --platform linux/amd64 hmctspublic.azurecr.io/base/java:17-distroless && docker tag hmctspublic.azurecr.io/base/java:17-distroless hmctspublic.azurecr.io/base/java/linux/amd64:17-distroless
when: ["-"]
keep: true

Expand All @@ -16,7 +16,7 @@ steps:
keep: true

- id: pull-base-image-arm64
cmd: docker pull --platform linux/arm64 hmctspublic.azurecr.io/base/java:11-distroless && docker tag hmctspublic.azurecr.io/base/java:11-distroless hmctspublic.azurecr.io/base/java/linux/arm64:11-distroless
cmd: docker pull --platform linux/arm64 hmctspublic.azurecr.io/base/java:17-distroless && docker tag hmctspublic.azurecr.io/base/java:17-distroless hmctspublic.azurecr.io/base/java/linux/arm64:17-distroless
when:
- pull-base-image-amd64
keep: true
Expand Down
129 changes: 66 additions & 63 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ plugins {

group = 'uk.gov.hmcts.reform.ccd'

sourceCompatibility = 11
targetCompatibility = 11
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

sourceSets {
integrationTest {
Expand Down Expand Up @@ -159,97 +162,97 @@ def versions = [
dependencies {
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-bootstrap', version: '3.0.1'

compile group: 'com.google.guava', name: 'guava', version:'30.1-jre'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13'
implementation group: 'com.google.guava', name: 'guava', version:'30.1-jre'
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13'

compile "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}"
compile "org.apache.tomcat.embed:tomcat-embed-el:${tomcatVersion}"
compile "org.apache.tomcat.embed:tomcat-embed-websocket:${tomcatVersion}"
implementation "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}"
implementation "org.apache.tomcat.embed:tomcat-embed-el:${tomcatVersion}"
implementation "org.apache.tomcat.embed:tomcat-embed-websocket:${tomcatVersion}"

// CVE-2021-28170
compile group: 'org.glassfish', name: 'jakarta.el', version: '4.0.1'
implementation group: 'org.glassfish', name: 'jakarta.el', version: '4.0.1'
// CVE-2021-42550
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.10'
implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.2.10'

compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-aop'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-json'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-json'

compile group: 'com.github.hmcts.java-logging', name: 'logging', version: versions.reformLogging
compile (group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-hystrix', version: '2.2.10.RELEASE') {
implementation group: 'com.github.hmcts.java-logging', name: 'logging', version: versions.reformLogging
implementation(group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-hystrix', version: '2.2.10.RELEASE') {
exclude group: 'org.springframework.security', module: 'spring-security-rsa'
}

// https://mvnrepository.com/artifact/com.github.tomakehurst/wiremock
compile (group: 'com.github.tomakehurst', name: 'wiremock-jre8', version: '2.35.0')
implementation(group: 'com.github.tomakehurst', name: 'wiremock-jre8', version: '2.35.0')
// https://mvnrepository.com/artifact/com.github.jknack/handlebars
implementation group: 'com.github.jknack', name: 'handlebars', version: '4.3.1'

compile group: 'org.eclipse.jetty', name: 'jetty-server', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-alpn-client', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-alpn-java-client', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-alpn-java-server', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-alpn-openjdk8-client', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-alpn-openjdk8-server', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-continuation', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-util', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-util-ajax', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-xml', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-client', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-security', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-http', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-io', version: jettyVersion
compile group: 'org.eclipse.jetty.http2', name: 'http2-server', version: jettyVersion
compile group: 'org.eclipse.jetty.http2', name: 'http2-common', version: jettyVersion
compile group: 'org.eclipse.jetty.http2', name: 'http2-hpack', version: jettyVersion

compile group: 'org.eclipse.jetty', name: 'jetty-servlet', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-servlets', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-proxy', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-alpn-server', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-alpn-conscrypt-server', version: jettyVersion
compile group: 'org.eclipse.jetty', name: 'jetty-alpn-conscrypt-client', version: jettyVersion

compile group: 'org.codehaus.groovy', name: 'groovy-json', version: groovyVersion
compile group: 'org.codehaus.groovy', name: 'groovy', version: groovyVersion
compile group: 'org.codehaus.groovy', name: 'groovy-xml', version: groovyVersion

compile group: 'com.nimbusds', name: 'nimbus-jose-jwt', version: '7.9'
compile group: 'org.springframework.security', name: 'spring-security-crypto'
implementation group: 'org.eclipse.jetty', name: 'jetty-server', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-alpn-client', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-alpn-java-client', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-alpn-java-server', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-alpn-openjdk8-client', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-alpn-openjdk8-server', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-continuation', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-util', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-util-ajax', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-xml', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-client', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-security', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-http', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-io', version: jettyVersion
implementation group: 'org.eclipse.jetty.http2', name: 'http2-server', version: jettyVersion
implementation group: 'org.eclipse.jetty.http2', name: 'http2-common', version: jettyVersion
implementation group: 'org.eclipse.jetty.http2', name: 'http2-hpack', version: jettyVersion

implementation group: 'org.eclipse.jetty', name: 'jetty-servlet', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-servlets', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-webapp', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-proxy', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-alpn-server', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-alpn-conscrypt-server', version: jettyVersion
implementation group: 'org.eclipse.jetty', name: 'jetty-alpn-conscrypt-client', version: jettyVersion

implementation group: 'org.codehaus.groovy', name: 'groovy-json', version: groovyVersion
implementation group: 'org.codehaus.groovy', name: 'groovy', version: groovyVersion
implementation group: 'org.codehaus.groovy', name: 'groovy-xml', version: groovyVersion

implementation group: 'com.nimbusds', name: 'nimbus-jose-jwt', version: '7.9'
implementation group: 'org.springframework.security', name: 'spring-security-crypto'


implementation group: 'commons-fileupload', name: 'commons-fileupload', version: '1.5'
compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.4'
compile group: 'commons-io', name: 'commons-io', version: '2.8.0'
implementation group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.4'
implementation group: 'commons-io', name: 'commons-io', version: '2.8.0'

testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: versions.junit
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: versions.junit
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: versions.junit
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: versions.junit

testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testCompile(group: 'io.rest-assured', name: 'rest-assured', version: '4.3.0') {
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testImplementation(group: 'io.rest-assured', name: 'rest-assured', version: '4.3.0') {
exclude group: 'org.apache.sling', module: 'org.apache.sling.javax.activation'
}
testCompile group: 'io.rest-assured', name: 'json-path', version: '4.3.0'
testCompile(group: 'io.rest-assured', name: 'xml-path', version: '4.3.0') {
testImplementation group: 'io.rest-assured', name: 'json-path', version: '4.3.0'
testImplementation(group: 'io.rest-assured', name: 'xml-path', version: '4.3.0') {
exclude group: 'org.apache.sling', module: 'org.apache.sling.javax.activation'
}

testCompile group: 'org.hamcrest', name: 'hamcrest', version: '2.2'
testCompile 'com.github.hmcts:fortify-client:1.3.0:all'
integrationTestCompile sourceSets.main.runtimeClasspath
integrationTestCompile sourceSets.test.runtimeClasspath
testImplementation group: 'org.hamcrest', name: 'hamcrest', version: '2.2'
testImplementation 'com.github.hmcts:fortify-client:1.3.0:all'
integrationTestImplementation sourceSets.main.runtimeClasspath
integrationTestImplementation sourceSets.test.runtimeClasspath

smokeTestCompile sourceSets.main.runtimeClasspath
smokeTestCompile sourceSets.test.runtimeClasspath
smokeTestImplementation sourceSets.main.runtimeClasspath
smokeTestImplementation sourceSets.test.runtimeClasspath

functionalTestCompile sourceSets.main.runtimeClasspath
functionalTestCompile sourceSets.test.runtimeClasspath
functionalTestImplementation sourceSets.main.runtimeClasspath
functionalTestImplementation sourceSets.test.runtimeClasspath

compile group: 'junit', name: 'junit', version: '4.13.1'
implementation group: 'junit', name: 'junit', version: '4.13.1'

implementation group: 'net.minidev', name: 'json-smart', version: '2.4.7'

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
53 changes: 33 additions & 20 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
##
## Gradle start up script for UN*X
Expand Down Expand Up @@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down Expand Up @@ -66,6 +82,7 @@ esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
Expand Down Expand Up @@ -109,10 +126,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand All @@ -138,19 +156,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

Expand All @@ -159,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "$@"
22 changes: 21 additions & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
Expand All @@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down Expand Up @@ -65,6 +84,7 @@ set CMD_LINE_ARGS=%*

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

Expand Down
9 changes: 0 additions & 9 deletions lib/AI-Agent.xml

This file was deleted.

5 changes: 5 additions & 0 deletions lib/applicationinsights.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"role": {
"name": "ccd-test-stubs-service"
}
}

0 comments on commit d39d09a

Please sign in to comment.