From 5b5c074f3d6e0426df7649ee76e374c39687618b Mon Sep 17 00:00:00 2001 From: Zipeng WU Date: Tue, 6 Dec 2022 11:32:02 +0100 Subject: [PATCH] SONAR-17565 Support running SonarQube with Java 17 --- .cirrus.yml | 26 +++++++++++++++++++ build.gradle | 3 +++ .../application/es/EsKeyStoreCliTest.java | 3 ++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index bfc10017e67..3e9f71bb73f 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -298,6 +298,32 @@ qa_task: - ./private/cirrus/cirrus-qa.sh postgres <<: *DEFAULT_ARTIFACTS_TEMPLATE +qa_java11_task: + <<: *DEFAULT_TEMPLATE + <<: *BUILD_DEPENDANT_TASK_TEMPLATE + <<: *GRADLE_CACHE_TEMPLATE + <<: *JAR_CACHE_TEMPLATE + gke_container: + dockerfile: private/docker/Dockerfile-build-java11 + builder_image_project: sonarqube-team + builder_image_name: family/docker-builder + cluster_name: cirrus-ci-cluster + zone: us-central1-a + namespace: default + cpu: 2 + memory: 6Gb + additional_containers: + - <<: *POSTGRES_ADDITIONAL_CONTAINER_TEMPLATE + env: + matrix: + - QA_CATEGORY: Cat1 + - QA_CATEGORY: CommunityEditionWithPlugins + - QA_CATEGORY: ComputeEngine + - QA_CATEGORY: Upgrade + script: + - ./private/cirrus/cirrus-qa.sh postgres + <<: *DEFAULT_ARTIFACTS_TEMPLATE + task: #bitbucket <<: *DEFAULT_TEMPLATE <<: *BUILD_DEPENDANT_TASK_TEMPLATE diff --git a/build.gradle b/build.gradle index 3b440b30bbf..62a1a37a745 100644 --- a/build.gradle +++ b/build.gradle @@ -146,6 +146,9 @@ subprojects { // do not deploy to Artifactory by default artifactoryPublish.skip = true + // Produce Java 11 bytecode while making sure the code does not use any APIs from Java 17 + compileJava.options.release = 11 + compileJava.options.encoding = "UTF-8" compileTestJava.options.encoding = "UTF-8" diff --git a/server/sonar-main/src/test/java/org/sonar/application/es/EsKeyStoreCliTest.java b/server/sonar-main/src/test/java/org/sonar/application/es/EsKeyStoreCliTest.java index 089200e62b4..5c508ad4021 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/es/EsKeyStoreCliTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/es/EsKeyStoreCliTest.java @@ -34,6 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -79,7 +80,7 @@ public class EsKeyStoreCliTest { "-Des.distribution.type=tar"); verify(process.getOutputStream()).write(argThat(new ArrayContainsMatcher("value1\nvalue2\nvalue3\n")), eq(0), eq(21)); - verify(process.getOutputStream()).flush(); + verify(process.getOutputStream(), atLeastOnce()).flush(); verify(process.getMock()).waitFor(1L, TimeUnit.MINUTES); } -- 2.39.5