diff --git a/.github/workflows/test-jdk8-compat-unit.yml b/.github/workflows/test-jdk8-compat-unit.yml index bf7bffc18..a5e73fce6 100644 --- a/.github/workflows/test-jdk8-compat-unit.yml +++ b/.github/workflows/test-jdk8-compat-unit.yml @@ -27,4 +27,4 @@ jobs: cache: 'gradle' - name: Run Unit Test - run: ./gradlew clean unitTest -Pcheck-jdk8-compatibility=true + run: ./gradlew clean unitTest -Druntime.java=8 diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index 982d3d957..6a3284204 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -7,7 +7,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - java: [ 11, 17, 21 ] + java: [ 8, 11, 17, 21 ] os: [ubuntu-latest, windows-latest, macOS-latest] steps: - name: Checkout Java Client @@ -21,4 +21,17 @@ jobs: cache: 'gradle' - name: Run Unit Test + if: ${{ matrix.java != 8 }} run: ./gradlew clean unitTest + + - name: Set up JDK 11 + uses: actions/setup-java@v3 + if: ${{ matrix.java == 8 }} + with: + java-version: 11 + distribution: 'temurin' + cache: 'gradle' + + - name: Run Unit Test + if: ${{ matrix.java == 8 }} + run: "./gradlew clean unitTest -Druntime.java=8" diff --git a/java-client/build.gradle.kts b/java-client/build.gradle.kts index dd29517d0..ea80a59f3 100644 --- a/java-client/build.gradle.kts +++ b/java-client/build.gradle.kts @@ -64,6 +64,12 @@ configurations { } } +val runtimeJavaVersion = (System.getProperty("runtime.java")?.toInt())?.let(JavaVersion::toVersion) ?: JavaVersion.current() +logger.quiet("=======================================") +logger.quiet(" Runtime JDK Version : " + runtimeJavaVersion) +logger.quiet(" Gradle JDK Version : " + JavaVersion.current()) +logger.quiet("=======================================") + java { targetCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8 @@ -74,6 +80,11 @@ java { registerFeature("awsSdk2Support") { usingSourceSet(sourceSets.get("main")) } + + toolchain { + languageVersion = JavaLanguageVersion.of(runtimeJavaVersion.majorVersion) + vendor = JvmVendorSpec.ADOPTIUM + } } tasks.withType { @@ -338,9 +349,7 @@ publishing { } } -// Use `-Pcheck-jdk8-compatibility=true` to -val jdk8compatibility = (project.findProperty("check-jdk8-compatibility") as String?).toBoolean() -if (JavaVersion.current() >= JavaVersion.VERSION_11 && jdk8compatibility == false) { +if (runtimeJavaVersion >= JavaVersion.VERSION_11) { val java11: SourceSet = sourceSets.create("java11") { java { compileClasspath += sourceSets.main.get().output + sourceSets.test.get().output @@ -372,17 +381,4 @@ if (JavaVersion.current() >= JavaVersion.VERSION_11 && jdk8compatibility == fals testClassesDirs += java11.output.classesDirs classpath = sourceSets["java11"].runtimeClasspath } -} else if (jdk8compatibility == true) { - java { - toolchain { - languageVersion = JavaLanguageVersion.of(8) - vendor = JvmVendorSpec.ADOPTIUM - } - } - - tasks.register("tests-jdk8") { - javaLauncher = javaToolchains.launcherFor { - languageVersion = JavaLanguageVersion.of(8) - } - } -} +} \ No newline at end of file