From 2b35f5d3210873a396262f9c532c73d284181473 Mon Sep 17 00:00:00 2001 From: Johannes Link Date: Sun, 12 Nov 2023 11:48:26 +0100 Subject: [PATCH] Use javaTargetVersion in (hopefully) all relevant places --- .github/workflows/matrix.js | 5 ++--- buildSrc/src/main/groovy/jqwik.common-configuration.gradle | 4 ++-- dependencies.gradle | 7 ++++--- documentation/build.gradle | 2 +- documentation/src/docs/include/kotlin-module.md | 2 +- kotlin/build.gradle | 2 +- test-modular-api/build.gradle | 7 +++++-- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/matrix.js b/.github/workflows/matrix.js index 9dcb24d10..fc5b7fb9a 100644 --- a/.github/workflows/matrix.js +++ b/.github/workflows/matrix.js @@ -41,7 +41,7 @@ matrix.addAxis({ '8', '11', '17', - '21 ', + '21', ] }); @@ -112,7 +112,7 @@ include.forEach(v => { let gradleArgs = [ `-Duser.country=${v.locale.country}`, `-Duser.language=${v.locale.language}`, - `-DjavaVersion=${v.java_version}`, + `-DjavaTargetVersion=${v.java_version}`, ]; v.extraGradleArgs = gradleArgs.join(' '); }); @@ -122,7 +122,6 @@ include.forEach(v => { // Pass locale via _JAVA_OPTIONS so all the forked processes inherit it jvmArgs.push(`-Duser.country=${v.locale.country}`); jvmArgs.push(`-Duser.language=${v.locale.language}`); - //jvmArgs.push(`-DjavaVersion=${v.java_version}`); // Is that necessary? if (v.jit === 'hotspot' && Math.random() > 0.5) { // The following options randomize instruction selection in JIT compiler // so it might reveal missing synchronization in TestNG code diff --git a/buildSrc/src/main/groovy/jqwik.common-configuration.gradle b/buildSrc/src/main/groovy/jqwik.common-configuration.gradle index df189d9ec..728422c59 100644 --- a/buildSrc/src/main/groovy/jqwik.common-configuration.gradle +++ b/buildSrc/src/main/groovy/jqwik.common-configuration.gradle @@ -41,8 +41,8 @@ publishing { java { withJavadocJar() withSourcesJar() - sourceCompatibility = JavaVersion.toVersion("${javaVersion}") - targetCompatibility = JavaVersion.toVersion("${javaVersion}") + sourceCompatibility = JavaVersion.toVersion("${javaTargetVersion}") + targetCompatibility = JavaVersion.toVersion("${javaTargetVersion}") } tasks.withType(JavaCompile) { diff --git a/dependencies.gradle b/dependencies.gradle index 52a4d84e8..1592510dd 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -23,8 +23,9 @@ static def showStandardStreams() { propSSS == null ? false : propSSS == "true" } -static def javaVersion() { - def propJV = System.getProperty("javaVersion") +static def javaTargetVersion() { + // 1.8 is default, because that's currently jqwik's minimum supported version + def propJV = System.getProperty("javaTargetVersion") propJV = propJV == '8' ? '1.8' : propJV propJV = propJV == null ? '1.8' : propJV propJV @@ -48,5 +49,5 @@ ext { jqwikVersion = '1.8.2-SNAPSHOT' isSnapshotRelease = isSnapshotRelease(jqwikVersion) showStandardStreams = showStandardStreams() - javaVersion = javaVersion() + javaTargetVersion = javaTargetVersion() } diff --git a/documentation/build.gradle b/documentation/build.gradle index f600bc778..9de089a9f 100644 --- a/documentation/build.gradle +++ b/documentation/build.gradle @@ -135,7 +135,7 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { "-Xjsr305=under-migration:strict", "-Xemit-jvm-type-annotations" // Required for annotations on type variables ] - kotlinOptions.jvmTarget = "1.8" + kotlinOptions.jvmTarget = "${javaTargetVersion}" kotlinOptions.javaParameters = true } diff --git a/documentation/src/docs/include/kotlin-module.md b/documentation/src/docs/include/kotlin-module.md index 65e40ef84..dc0ed8be5 100644 --- a/documentation/src/docs/include/kotlin-module.md +++ b/documentation/src/docs/include/kotlin-module.md @@ -57,7 +57,7 @@ tasks.withType().configureEach { tasks.withType { kotlinOptions { freeCompilerArgs = listOf( - "-Xjsr305=strict", // Required for strict interpretation of + "-Xjsr305=strict", // For strict type warnings "-Xemit-jvm-type-annotations" // Required for annotations on type variables ) jvmTarget = "11" // 1.8 or above diff --git a/kotlin/build.gradle b/kotlin/build.gradle index 95a513531..c59d41c6a 100644 --- a/kotlin/build.gradle +++ b/kotlin/build.gradle @@ -77,7 +77,7 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { // "-Xjsr305=under-migration:strict", // @UnderMigration not used in jqwik "-Xemit-jvm-type-annotations" // Required for annotations on type variables ] - kotlinOptions.jvmTarget = "${javaVersion}" + kotlinOptions.jvmTarget = "${javaTargetVersion}" kotlinOptions.javaParameters = true // Required to get correct parameter names in reporting } diff --git a/test-modular-api/build.gradle b/test-modular-api/build.gradle index 7aebe24b4..40edda82f 100644 --- a/test-modular-api/build.gradle +++ b/test-modular-api/build.gradle @@ -13,9 +13,12 @@ repositories { maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } } +def localJavaTarget = "${javaTargetVersion}" == "1.8" ? JavaVersion.VERSION_1_9 + : JavaVersion.toVersion("${javaTargetVersion}") + java { - sourceCompatibility = JavaVersion.VERSION_1_9 - targetCompatibility = JavaVersion.VERSION_1_9 + sourceCompatibility = localJavaTarget + targetCompatibility = localJavaTarget modularity.inferModulePath = true }