Skip to content

Relax Kotlin contracts for Executable parameters #4481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 11 commits into
base: marc/jdk17
Choose a base branch
from
7 changes: 7 additions & 0 deletions .github/actions/setup-test-jdk/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@ runs:
check-latest: true
- shell: bash
run: echo "JDK8=$JAVA_HOME" >> $GITHUB_ENV
- uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4
with:
distribution: ${{ inputs.distribution }}
java-version: 17
check-latest: true
- shell: bash
run: echo "JDK17=$JAVA_HOME" >> $GITHUB_ENV
4 changes: 2 additions & 2 deletions documentation/documentation.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ val modularProjects: List<Project> by rootProject
modularProjects.forEach { evaluationDependsOn(it.path) }

javaLibrary {
mainJavaVersion = JavaVersion.VERSION_1_8
testJavaVersion = JavaVersion.VERSION_1_8
mainJavaVersion = JavaVersion.VERSION_17
testJavaVersion = JavaVersion.VERSION_17
}

val apiReport = configurations.dependencyScope("apiReport")
Expand Down
2 changes: 2 additions & 0 deletions documentation/src/docs/asciidoc/release-notes/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ authors as well as build tool and IDE vendors.

include::{includedir}/link-attributes.adoc[]

include::{basedir}/release-notes-6.0.0-M1.adoc[]

include::{basedir}/release-notes-5.13.0-M3.adoc[]

include::{basedir}/release-notes-5.13.0-M2.adoc[]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[[release-notes-6.0.0-M1]]
== 6.0.0-M1

*Date of Release:* ❓

*Scope:* ❓

For a complete list of all _closed_ issues and pull requests for this release, consult the
link:{junit5-repo}+/milestone/87?closed=1+[6.0.0-M1] milestone page in the JUnit
repository on GitHub.


[[release-notes-6.0.0-M1-overall-improvements]]
=== Overall Improvements

[[release-notes-6.0.0-M1-overall-bug-fixes]]
==== Bug Fixes

* ❓

[[release-notes-6.0.0-M1-overall-deprecations-and-breaking-changes]]
==== Deprecations and Breaking Changes

* Minimum required Java version is now Java 17.

[[release-notes-6.0.0-M1-overall-new-features-and-improvements]]
==== New Features and Improvements

* ❓


[[release-notes-6.0.0-M1-junit-platform]]
=== JUnit Platform

[[release-notes-6.0.0-M1-junit-platform-bug-fixes]]
==== Bug Fixes

* ❓

[[release-notes-6.0.0-M1-junit-platform-deprecations-and-breaking-changes]]
==== Deprecations and Breaking Changes

* ❓

[[release-notes-6.0.0-M1-junit-platform-new-features-and-improvements]]
==== New Features and Improvements

* ❓


[[release-notes-6.0.0-M1-junit-jupiter]]
=== JUnit Jupiter

[[release-notes-6.0.0-M1-junit-jupiter-bug-fixes]]
==== Bug Fixes

* ❓

[[release-notes-6.0.0-M1-junit-jupiter-deprecations-and-breaking-changes]]
==== Deprecations and Breaking Changes

* ❓

[[release-notes-6.0.0-M1-junit-jupiter-new-features-and-improvements]]
==== New Features and Improvements

* ❓


[[release-notes-6.0.0-M1-junit-vintage]]
=== JUnit Vintage

[[release-notes-6.0.0-M1-junit-vintage-bug-fixes]]
==== Bug Fixes

* ❓

[[release-notes-6.0.0-M1-junit-vintage-deprecations-and-breaking-changes]]
==== Deprecations and Breaking Changes

* ❓

[[release-notes-6.0.0-M1-junit-vintage-new-features-and-improvements]]
==== New Features and Improvements

* ❓
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ org.gradle.jvmargs=-Xmx1g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryEr
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.configuration-cache.parallel=true
org.gradle.java.installations.fromEnv=JDK8,JDK18,JDK19,JDK20,JDK21,JDK22,JDK23,JDK24
org.gradle.java.installations.fromEnv=JDK8,JDK17,JDK21,JDK23,JDK24,JDK25
org.gradle.kotlin.dsl.allWarningsAsErrors=true
org.gradle.warning.mode=fail

Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ jmh = { id = "me.champeau.jmh", version = "0.7.3" }
# check if workaround in gradle.properties can be removed when updating
kotlin = { id = "org.jetbrains.kotlin.jvm", version = "2.1.20" }
nexusPublish = { id = "io.github.gradle-nexus.publish-plugin", version = "2.0.0" }
openrewrite = { id = "org.openrewrite.rewrite", version = "7.1.7" }
plantuml = { id = "io.freefair.plantuml", version = "8.13.1" }
shadow = { id = "com.gradleup.shadow", version = "8.3.6" }
spotless = { id = "com.diffplug.spotless", version = "6.25.0" }
Expand Down
1 change: 1 addition & 0 deletions gradle/plugins/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies {
implementation(libs.plugins.develocity.markerCoordinates)
implementation(libs.plugins.foojayResolver.markerCoordinates)
implementation(libs.plugins.jmh.markerCoordinates)
implementation(libs.plugins.openrewrite.markerCoordinates)
implementation(libs.plugins.shadow.markerCoordinates)
implementation(libs.plugins.spotless.markerCoordinates)
implementation(libs.plugins.versions.markerCoordinates)
Expand Down
16 changes: 12 additions & 4 deletions gradle/plugins/common/src/main/kotlin/JavaLibraryExtension.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import org.gradle.api.JavaVersion
import org.gradle.api.provider.Property

@Suppress("LeakingThis")
abstract class JavaLibraryExtension {

abstract val mainJavaVersion: Property<JavaVersion>
abstract val testJavaVersion: Property<JavaVersion>

init {
mainJavaVersion.convention(JavaVersion.VERSION_17)
testJavaVersion.convention(JavaVersion.VERSION_21)
}

open class JavaLibraryExtension {
var mainJavaVersion: JavaVersion = JavaVersion.VERSION_1_8
var testJavaVersion: JavaVersion = JavaVersion.VERSION_21
var configureRelease: Boolean = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ plugins {
id("junitbuild.build-parameters")
id("junitbuild.checkstyle-conventions")
id("junitbuild.jacoco-java-conventions")
id("org.openrewrite.rewrite")
}

rewrite {
activeRecipe("org.openrewrite.java.migrate.UpgradeToJava17")
}

dependencies {
rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:latest.release"))
rewrite("org.openrewrite.recipe:rewrite-migrate-java")
}

val mavenizedProjects: List<Project> by rootProject.extra
Expand Down Expand Up @@ -184,10 +194,8 @@ val compileModule by tasks.registering(JavaCompile::class) {
enabled = project in modularProjects
source = fileTree(combinedModuleSourceDir).builtBy(prepareModuleSourceDir)
destinationDirectory = moduleOutputDir
sourceCompatibility = "9"
targetCompatibility = "9"
classpath = files()
options.release = 9
options.release = 17
options.compilerArgs.addAll(listOf(
// Suppress warnings for automatic modules: org.apiguardian.api, org.opentest4j
"-Xlint:all,-requires-automatic,-requires-transitive-automatic",
Expand Down Expand Up @@ -262,17 +270,14 @@ tasks.withType<JavaCompile>().configureEach {
}

tasks.compileJava {
// See: https://docs.oracle.com/en/java/javase/12/tools/javac.html
options.compilerArgs.addAll(listOf(
"-Xlint:all", // Enables all recommended warnings.
"-Werror", // Terminates compilation when warnings occur.
// Required for compatibility with Java 8's reflection APIs (see https://github.com/junit-team/junit5/issues/3797).
"-parameters", // Generates metadata for reflection on method parameters.
))
}

tasks.compileTestJava {
// See: https://docs.oracle.com/en/java/javase/12/tools/javac.html
options.compilerArgs.addAll(listOf(
"-Xlint", // Enables all recommended warnings.
"-Xlint:-overrides", // Disables "method overrides" warnings.
Expand All @@ -281,47 +286,39 @@ tasks.compileTestJava {
))
}

afterEvaluate {
configurations {
apiElements {
attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, extension.mainJavaVersion.majorVersion.toInt())
}
}
runtimeElements {
attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, extension.mainJavaVersion.majorVersion.toInt())
}
configurations {
apiElements {
attributes {
attributeProvider(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, extension.mainJavaVersion.map { it.majorVersion.toInt() })
}
}
tasks {
compileJava {
if (extension.configureRelease) {
options.release = extension.mainJavaVersion.majorVersion.toInt()
} else {
sourceCompatibility = extension.mainJavaVersion.majorVersion
targetCompatibility = extension.mainJavaVersion.majorVersion
}
}
compileTestJava {
if (extension.configureRelease) {
options.release = extension.testJavaVersion.majorVersion.toInt()
} else {
sourceCompatibility = extension.testJavaVersion.majorVersion
targetCompatibility = extension.testJavaVersion.majorVersion
}
runtimeElements {
attributes {
attributeProvider(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, extension.mainJavaVersion.map { it.majorVersion.toInt() })
}
}
}

tasks {
compileJava {
options.release = extension.mainJavaVersion.map { it.majorVersion.toInt() }
}
compileTestJava {
options.release = extension.testJavaVersion.map { it.majorVersion.toInt() }
}
}

afterEvaluate {
pluginManager.withPlugin("groovy") {
tasks.named<GroovyCompile>("compileGroovy").configure {
// Groovy compiler does not support the --release flag.
sourceCompatibility = extension.mainJavaVersion.majorVersion
targetCompatibility = extension.mainJavaVersion.majorVersion
sourceCompatibility = extension.mainJavaVersion.get().majorVersion
targetCompatibility = extension.mainJavaVersion.get().majorVersion
}
tasks.named<GroovyCompile>("compileTestGroovy").configure {
// Groovy compiler does not support the --release flag.
sourceCompatibility = extension.testJavaVersion.majorVersion
targetCompatibility = extension.testJavaVersion.majorVersion
sourceCompatibility = extension.testJavaVersion.get().majorVersion
targetCompatibility = extension.testJavaVersion.get().majorVersion
}
}
}
Expand All @@ -340,6 +337,6 @@ pluginManager.withPlugin("java-test-fixtures") {
config = resources.text.fromFile(checkstyle.configDirectory.file("checkstyleTest.xml"))
}
tasks.named<JavaCompile>("compileTestFixturesJava") {
options.release = extension.testJavaVersion.majorVersion.toInt()
options.release = extension.testJavaVersion.map { it.majorVersion.toInt() }
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_1
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
Expand All @@ -11,26 +11,19 @@ tasks.named("kotlinSourcesJar") {
enabled = false
}

val javaLibraryExtension = project.the<JavaLibraryExtension>()

tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
apiVersion = KotlinVersion.fromVersion("1.6")
jvmTarget = javaLibraryExtension.mainJavaVersion.map { JvmTarget.fromTarget(it.toString()) }
apiVersion = KOTLIN_2_1
languageVersion = apiVersion
allWarningsAsErrors = false
// Compiler arg is required for Kotlin 1.6 and below
// see https://kotlinlang.org/docs/whatsnew17.html#stable-opt-in-requirements
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
allWarningsAsErrors.convention(true)
javaParameters = true
freeCompilerArgs.addAll("-opt-in=kotlin.RequiresOptIn")
}
}

afterEvaluate {
val extension = project.the<JavaLibraryExtension>()
tasks {
withType<KotlinCompile>().configureEach {
compilerOptions.jvmTarget = JvmTarget.fromTarget(extension.mainJavaVersion.toString())
compilerOptions.javaParameters = true
}
named<KotlinCompile>("compileTestKotlin") {
compilerOptions.jvmTarget = JvmTarget.fromTarget(extension.testJavaVersion.toString())
}
}
tasks.named<KotlinCompile>("compileTestKotlin") {
compilerOptions.jvmTarget = javaLibraryExtension.testJavaVersion.map { JvmTarget.fromTarget(it.toString()) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ tasks.withType<Jar>().named {
val osgiProperties by tasks.registering(WriteProperties::class) {
destinationFile = layout.buildDirectory.file("verifyOSGiProperties.bndrun")
property("-standalone", true)
project.extensions.getByType(JavaLibraryExtension::class.java).let { javaLibrary ->
property("-runee", "JavaSE-${javaLibrary.mainJavaVersion}")
project.extensions.getByType(JavaLibraryExtension::class).let { javaLibrary ->
property("-runee", Callable { "JavaSE-${javaLibrary.mainJavaVersion.get()}" })
}
property("-runrequires", "osgi.identity;filter:='(osgi.identity=${project.name})'")
property("-runsystempackages", "jdk.internal.misc,jdk.jfr,sun.misc")
Expand Down
Loading