From bb036a39f3067330c66b75363c25529b856f01a2 Mon Sep 17 00:00:00 2001 From: Oleg Yukhnevich Date: Fri, 1 Dec 2023 07:46:03 +0200 Subject: [PATCH] Fix enum test, add toolchains and running on JDK 21 (#3376) --- .github/workflows/tests-thorough.yml | 2 +- dokka-integration-tests/settings.gradle.kts | 4 ++++ dokka-runners/runner-cli/settings.gradle.kts | 4 ++++ .../settings.gradle.kts | 4 ++++ .../runner-maven-plugin/settings.gradle.kts | 4 ++++ .../test/documentable/ObviousFunctionsTest.kt | 21 ++++++++++++++----- settings.gradle.kts | 1 + 7 files changed, 34 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests-thorough.yml b/.github/workflows/tests-thorough.yml index 8216bccded..8450fa6b9b 100644 --- a/.github/workflows/tests-thorough.yml +++ b/.github/workflows/tests-thorough.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: os: [ ubuntu-latest, windows-latest, macos-latest ] - javaVersion: [ 8, 11, 17 ] + javaVersion: [ 8, 11, 17, 21 ] fail-fast: false runs-on: ${{ matrix.os }} steps: diff --git a/dokka-integration-tests/settings.gradle.kts b/dokka-integration-tests/settings.gradle.kts index 07f1f59d9d..c8fb69bbef 100644 --- a/dokka-integration-tests/settings.gradle.kts +++ b/dokka-integration-tests/settings.gradle.kts @@ -15,6 +15,10 @@ pluginManagement { } } +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0" +} + dependencyResolutionManagement { repositories { mavenCentral() diff --git a/dokka-runners/runner-cli/settings.gradle.kts b/dokka-runners/runner-cli/settings.gradle.kts index 37b36fda47..24be63fb95 100644 --- a/dokka-runners/runner-cli/settings.gradle.kts +++ b/dokka-runners/runner-cli/settings.gradle.kts @@ -15,6 +15,10 @@ pluginManagement { } } +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0" +} + dependencyResolutionManagement { repositories { mavenCentral() diff --git a/dokka-runners/runner-gradle-plugin-classic/settings.gradle.kts b/dokka-runners/runner-gradle-plugin-classic/settings.gradle.kts index 24f21fe1cc..79e79482c7 100644 --- a/dokka-runners/runner-gradle-plugin-classic/settings.gradle.kts +++ b/dokka-runners/runner-gradle-plugin-classic/settings.gradle.kts @@ -15,6 +15,10 @@ pluginManagement { } } +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0" +} + dependencyResolutionManagement { repositories { mavenCentral() diff --git a/dokka-runners/runner-maven-plugin/settings.gradle.kts b/dokka-runners/runner-maven-plugin/settings.gradle.kts index 63bf374367..4178716123 100644 --- a/dokka-runners/runner-maven-plugin/settings.gradle.kts +++ b/dokka-runners/runner-maven-plugin/settings.gradle.kts @@ -15,6 +15,10 @@ pluginManagement { } } +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0" +} + dependencyResolutionManagement { repositories { mavenCentral() diff --git a/dokka-subprojects/analysis-kotlin-api/src/test/kotlin/org/jetbrains/dokka/analysis/test/documentable/ObviousFunctionsTest.kt b/dokka-subprojects/analysis-kotlin-api/src/test/kotlin/org/jetbrains/dokka/analysis/test/documentable/ObviousFunctionsTest.kt index c113742e7a..ac851f1cf6 100644 --- a/dokka-subprojects/analysis-kotlin-api/src/test/kotlin/org/jetbrains/dokka/analysis/test/documentable/ObviousFunctionsTest.kt +++ b/dokka-subprojects/analysis-kotlin-api/src/test/kotlin/org/jetbrains/dokka/analysis/test/documentable/ObviousFunctionsTest.kt @@ -121,13 +121,24 @@ class ObviousFunctionsTest { assertNotNull(enum) assertEquals("Enum", enum.name) + val javaVersion = when (val specVersion = System.getProperty("java.specification.version")) { + "1.8" -> 8 + else -> specVersion.toInt() + } + + // inherited from java enum + val jdkEnumInheritedFunctions = when { + // starting from JDK 18, 'finalize' is not available (finalization is deprecated in JDK 18) + javaVersion >= 18 -> setOf("clone", "getDeclaringClass", "describeConstable") + // starting from JDK 12, there is a new member in enum 'describeConstable' + javaVersion >= 12 -> setOf("clone", "getDeclaringClass", "describeConstable", "finalize") + else -> setOf("clone", "getDeclaringClass", "finalize") + } + assertObviousFunctions( expectedObviousFunctions = emptySet(), - expectedNonObviousFunctions = setOf( - "compareTo", "equals", "hashCode", "toString", - // inherited from java enum - "clone", "finalize", "getDeclaringClass" - ), + expectedNonObviousFunctions = setOf("compareTo", "equals", "hashCode", "toString") + + jdkEnumInheritedFunctions, actualFunctions = enum.functions ) } diff --git a/settings.gradle.kts b/settings.gradle.kts index ee2021e74d..e53d719a2a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -56,6 +56,7 @@ dependencyResolutionManagement { plugins { `gradle-enterprise` + id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0" } includeBuild("dokka-integration-tests")