From 899fc154d1c9fd274440ea4a2974f9549af18de1 Mon Sep 17 00:00:00 2001 From: gabilang Date: Thu, 6 Jul 2023 14:08:58 +0530 Subject: [PATCH] Migrate to Java 17 --- .github/workflows/build-dev-branches.yml | 16 ++++++++-------- .github/workflows/build-main.yml | 8 ++++---- .github/workflows/central-publish.yml | 8 ++++---- .github/workflows/daily-build.yml | 8 ++++---- .github/workflows/graalvm-check.yml | 2 +- .github/workflows/publish-release.yml | 8 ++++---- .github/workflows/pull-request.yml | 16 ++++++++-------- README.md | 4 ++-- build-config/checkstyle/build.gradle | 4 ++-- build.gradle | 8 ++++---- gradle.properties | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- prometheus-extension-ballerina/build.gradle | 2 +- .../prometheus/PrometheusMetricsTestCase.java | 7 +++++-- 14 files changed, 49 insertions(+), 46 deletions(-) diff --git a/.github/workflows/build-dev-branches.yml b/.github/workflows/build-dev-branches.yml index 4761295..e5e4631 100644 --- a/.github/workflows/build-dev-branches.yml +++ b/.github/workflows/build-dev-branches.yml @@ -13,12 +13,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: distribution: adopt - java-version: 11 + java-version: 17 - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle @@ -37,12 +37,12 @@ jobs: runs-on: windows-latest steps: - name: Checkout Repository - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: distribution: adopt - java-version: 11 + java-version: 17 - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle diff --git a/.github/workflows/build-main.yml b/.github/workflows/build-main.yml index 36f1af8..ac6e339 100644 --- a/.github/workflows/build-main.yml +++ b/.github/workflows/build-main.yml @@ -12,12 +12,12 @@ jobs: if: github.repository_owner == 'ballerina-platform' steps: - name: Checkout Repository - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: distribution: adopt - java-version: 11 + java-version: 17 - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle diff --git a/.github/workflows/central-publish.yml b/.github/workflows/central-publish.yml index 2a4c9fe..b06b9b3 100644 --- a/.github/workflows/central-publish.yml +++ b/.github/workflows/central-publish.yml @@ -17,12 +17,12 @@ jobs: runs-on: ubuntu-latest if: github.repository_owner == 'ballerina-platform' steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 11 + java-version: 17 - name: Build with Gradle env: packageUser: ${{ github.actor }} diff --git a/.github/workflows/daily-build.yml b/.github/workflows/daily-build.yml index a2f0425..6637b58 100644 --- a/.github/workflows/daily-build.yml +++ b/.github/workflows/daily-build.yml @@ -10,13 +10,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - name: Set up JDK 11 - uses: actions/setup-java@v2 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: distribution: adopt - java-version: 11 + java-version: 17 # Build the project with Gradle - name: Build with Gradle diff --git a/.github/workflows/graalvm-check.yml b/.github/workflows/graalvm-check.yml index 74c33f2..5701fe4 100644 --- a/.github/workflows/graalvm-check.yml +++ b/.github/workflows/graalvm-check.yml @@ -16,7 +16,7 @@ jobs: uses: graalvm/setup-graalvm@v1 with: version: 'latest' - java-version: '11' + java-version: '17' components: 'native-image' github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 5cbd380..55a5885 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -8,12 +8,12 @@ jobs: if: github.repository_owner == 'ballerina-platform' steps: - name: Checkout Repository - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: distribution: adopt - java-version: 11 + java-version: 17 - name: Set version env variable run: echo "VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev)" >> $GITHUB_ENV - name: Pre release depenency version update diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index b36d3e7..bfaa44e 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -7,12 +7,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: distribution: adopt - java-version: 11 + java-version: 17 - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle @@ -31,12 +31,12 @@ jobs: runs-on: windows-latest steps: - name: Checkout Repository - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: distribution: adopt - java-version: 11 + java-version: 17 - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle diff --git a/README.md b/README.md index e0c93f4..4ecafe1 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ ### Setting Up the Prerequisites -1. Download and install Java SE Development Kit (JDK) version 11 (from one of the following locations). +1. Download and install Java SE Development Kit (JDK) version 17 (from one of the following locations). - * [Oracle](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html) + * [Oracle](https://www.oracle.com/java/technologies/downloads/) * [OpenJDK](https://adoptopenjdk.net/) diff --git a/build-config/checkstyle/build.gradle b/build-config/checkstyle/build.gradle index 631670a..46c91c9 100644 --- a/build-config/checkstyle/build.gradle +++ b/build-config/checkstyle/build.gradle @@ -21,8 +21,8 @@ plugins { task downloadFiles(type: Download) { src([ - 'https://raw.githubusercontent.com/wso2/code-quality-tools/v1.3/checkstyle/checkstyle.xml', - 'https://raw.githubusercontent.com/wso2/code-quality-tools/v1.3/checkstyle/suppressions.xml' + 'https://raw.githubusercontent.com/wso2/code-quality-tools/v1.4/checkstyle/jdk-17/checkstyle.xml', + 'https://raw.githubusercontent.com/wso2/code-quality-tools/v1.4/checkstyle/jdk-17/suppressions.xml' ]) overwrite false onlyIfNewer true diff --git a/build.gradle b/build.gradle index f8dfdb5..e81e540 100644 --- a/build.gradle +++ b/build.gradle @@ -16,9 +16,9 @@ plugins { id 'checkstyle' - id "com.github.spotbugs" version "4.5.1" + id "com.github.spotbugs" version "5.0.14" id "net.researchgate.release" version "2.8.0" - id "de.undercouch.download" version "4.0.4" + id "de.undercouch.download" version "5.4.0" id 'jacoco' } @@ -57,7 +57,7 @@ allprojects { } subprojects { - apply plugin: 'java' + apply plugin: 'java-library' apply plugin: 'checkstyle' apply plugin: 'com.github.spotbugs' @@ -98,7 +98,7 @@ subprojects { } checkstyle { - toolVersion '8.18' + toolVersion '10.12.1' } spotbugsMain { diff --git a/gradle.properties b/gradle.properties index 014ab9c..c1d863d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -43,5 +43,5 @@ stdlibOAuth2Version=2.2.1 stdlibUuidVersion=1.2.1 # Test Dependency Versions -testngVersion=6.14.3 +testngVersion=7.6.1 slf4jVersion=1.7.26 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4c5803d..98debb8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/prometheus-extension-ballerina/build.gradle b/prometheus-extension-ballerina/build.gradle index 907534d..997f5b0 100644 --- a/prometheus-extension-ballerina/build.gradle +++ b/prometheus-extension-ballerina/build.gradle @@ -94,7 +94,7 @@ def tomlVersion = stripBallerinaExtensionVersion("${project.version}") def ballerinaCentralAccessToken = System.getenv('BALLERINA_CENTRAL_ACCESS_TOKEN') def originalConfig = ballerinaConfigFile.text def originalDependencyConfig = ballerinaDependencyFile.text -def artifactJars = file("$project.projectDir/target/cache/${packageOrg}/${packageName}/${tomlVersion}/java11/") +def artifactJars = file("$project.projectDir/target/cache/${packageOrg}/${packageName}/${tomlVersion}/java17/") def platform = "any" def distributionBinPath = "${project.buildDir.absolutePath}/extracted-distributions/jballerina-tools-zip/jballerina-tools-${ballerinaLangVersion}/bin" diff --git a/prometheus-extension-tests/src/test/java/io/ballerina/observe/metrics/prometheus/PrometheusMetricsTestCase.java b/prometheus-extension-tests/src/test/java/io/ballerina/observe/metrics/prometheus/PrometheusMetricsTestCase.java index 9a00958..b41ebe5 100644 --- a/prometheus-extension-tests/src/test/java/io/ballerina/observe/metrics/prometheus/PrometheusMetricsTestCase.java +++ b/prometheus-extension-tests/src/test/java/io/ballerina/observe/metrics/prometheus/PrometheusMetricsTestCase.java @@ -29,6 +29,7 @@ import org.testng.annotations.Test; import java.io.File; +import java.net.InetAddress; import java.nio.file.Paths; import java.util.HashMap; import java.util.List; @@ -140,7 +141,8 @@ public void testPrometheusMetrics(String prometheusServiceBindAddress, String pr int[] requiredPorts = {9091, prometheusPort}; serverInstance.startServer(balFile, new String[]{"--observability-included"}, null, env, requiredPorts); - Utils.waitForPortsToOpen(requiredPorts, 1000 * 60, false, "localhost"); + InetAddress inetAddress = InetAddress.getByName("localhost"); + Utils.waitForPortsToOpen(requiredPorts, 1000 * 60, false, inetAddress); prometheusExtLogLeecher.waitForText(10000); // Send requests to generate metrics @@ -193,7 +195,8 @@ public void testPrometheusDisabled() throws Exception { .getAbsolutePath(); int[] requiredPorts = {9091}; serverInstance.startServer(balFile, null, null, requiredPorts); - Utils.waitForPortsToOpen(requiredPorts, 1000 * 60, false, "localhost"); + InetAddress inetAddress = InetAddress.getByName("localhost"); + Utils.waitForPortsToOpen(requiredPorts, 1000 * 60, false, inetAddress); String responseData = HttpClientRequest.doGet(TEST_RESOURCE_URL).getData(); Assert.assertEquals(responseData, "Sum: 53");