From 2b0a63f3565f620f7212a822aee2575a46f44897 Mon Sep 17 00:00:00 2001 From: Vadim Mishenev Date: Wed, 1 Nov 2023 18:46:55 +0200 Subject: [PATCH 1/3] Update Kotlin compiler and KGP to 1.9.20-RC2 (#3262) * Update Kotlin compiler to 1.9.20-RC2 The current changes are related to https://github.com/JetBrains/kotlin/commit/d797505f06d640b666829bbfb4b7d7c67f812026 * Update KGP to 1.9.20-RC2 * Replace common stdlib in unit tests * Update Kotlin version in integration tests * Fix `Multiplatform0GradleIntegrationTest` * Turn WasmGradleIntegrationTest off for Kotlin 1.9.20-RC2 --- .../main/kotlin/testApi/testRunner/TestRunner.kt | 11 +++++------ gradle/libs.versions.toml | 4 ++-- .../projects/it-multiplatform-0/build.gradle.kts | 2 +- .../projects/it-multiplatform-0/gradle.properties | 4 ---- .../gradle/Multiplatform0GradleIntegrationTest.kt | 14 +++++++++++++- .../jetbrains/dokka/it/gradle/TestedVersions.kt | 5 +++-- .../dokka/it/gradle/WasmGradleIntegrationTest.kt | 3 ++- integration-tests/maven/projects/it-maven/pom.xml | 2 +- .../resolve/DokkaJsResolverForModuleFactory.kt | 1 - .../DokkaKlibMetadataCommonDependencyContainer.kt | 7 ++----- 10 files changed, 29 insertions(+), 24 deletions(-) diff --git a/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt b/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt index 0958ea14ae..1f7ee060f4 100644 --- a/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt +++ b/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt @@ -191,12 +191,11 @@ public abstract class AbstractTest, D : Dokk ?.replaceAfter(".jar", "") } - protected val commonStdlibPath: String? by lazy { - // TODO: feels hacky, find a better way to do it - ClassLoader.getSystemResource("kotlin/UInt.kotlin_metadata") - ?.file - ?.replace("file:", "") - ?.replaceAfter(".jar", "") + protected val commonStdlibPath: String? by lazy { + // `kotlin-stdlib-common` is legacy + // we can use any platform dependency + // since common code should be resolved with all platform + jvmStdlibPath } protected val stdlibExternalDocumentationLink: ExternalDocumentationLinkImpl = ExternalDocumentationLinkImpl( diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e3f190fb82..034c09cb1f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] -gradlePlugin-kotlin = "1.9.10" +gradlePlugin-kotlin = "1.9.20-RC2" # See: https://kotlinlang.org/docs/gradle-configure-project.html#apply-the-plugin gradlePlugin-android = "4.2.2" gradlePlugin-dokka = "1.9.10" @@ -10,7 +10,7 @@ kotlinx-collections-immutable = "0.3.6" kotlinx-bcv = "0.13.2" ## Analysis -kotlin-compiler = "1.9.10" +kotlin-compiler = "1.9.20-RC2" kotlin-compiler-k2 = "2.0.0-dev-5387" # MUST match the version of the intellij platform used in the kotlin compiler, diff --git a/integration-tests/gradle/projects/it-multiplatform-0/build.gradle.kts b/integration-tests/gradle/projects/it-multiplatform-0/build.gradle.kts index ab7a8fb5ab..a00b4b8d45 100644 --- a/integration-tests/gradle/projects/it-multiplatform-0/build.gradle.kts +++ b/integration-tests/gradle/projects/it-multiplatform-0/build.gradle.kts @@ -16,7 +16,7 @@ kotlin { jvm() linuxX64("linux") macosX64("macos") - js(BOTH) + js(IR) // Starting with Kotlin 1.9.0, using compiler types LEGACY or BOTH leads to an error. //TODO Add wasm when kx.coroutines will be supported and published into the main repo sourceSets { val commonMain by sourceSets.getting diff --git a/integration-tests/gradle/projects/it-multiplatform-0/gradle.properties b/integration-tests/gradle/projects/it-multiplatform-0/gradle.properties index 4d8f284781..1e2686effb 100644 --- a/integration-tests/gradle/projects/it-multiplatform-0/gradle.properties +++ b/integration-tests/gradle/projects/it-multiplatform-0/gradle.properties @@ -3,7 +3,3 @@ # dokka_it_kotlin_version=1.9.10 -#these flags are enabled by default since 1.6.20. -#remove when this test is executed with Kotlin >= 1.6.20 -kotlin.mpp.enableGranularSourceSetsMetadata=true -kotlin.native.enableDependencyPropagation=false diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt index e43bc05985..d8f5cee254 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt @@ -27,7 +27,19 @@ class Multiplatform0GradleIntegrationTest : AbstractGradleIntegrationTest() { @ParameterizedTest(name = "{0}") @ArgumentsSource(AllSupportedTestedVersionsArgumentsProvider::class) fun execute(buildVersions: BuildVersions) { - val result = createGradleRunner(buildVersions, "dokkaHtml", "-i", "-s").buildRelaxed() + // `enableGranularSourceSetsMetadata` and `enableDependencyPropagation` flags are enabled by default since 1.6.20. + // remove when this test is executed with Kotlin >= 1.6.20 + val result = if (buildVersions.kotlinVersion < "1.6.20") + createGradleRunner( + buildVersions, + "dokkaHtml", + "-i", + "-s", + "-Pkotlin.mpp.enableGranularSourceSetsMetadata=true", + "-Pkotlin.native.enableDependencyPropagation=false" + ).buildRelaxed() + else + createGradleRunner(buildVersions, "dokkaHtml", "-i", "-s").buildRelaxed() assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":dokkaHtml")).outcome) diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/TestedVersions.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/TestedVersions.kt index 3493879a97..e4634c0911 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/TestedVersions.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/TestedVersions.kt @@ -14,7 +14,7 @@ internal open class AllSupportedTestedVersionsArgumentsProvider : TestedVersions internal object TestedVersions { - val LATEST = BuildVersions("7.6.2", "1.9.10") + val LATEST = BuildVersions("7.6.2", "1.9.20-RC2") /** * All supported Gradle/Kotlin versions, including [LATEST] @@ -24,7 +24,7 @@ internal object TestedVersions { val ALL_SUPPORTED = BuildVersions.permutations( gradleVersions = listOf("7.6.2"), - kotlinVersions = listOf("1.9.0", "1.8.20", "1.7.20", "1.6.21", "1.5.31"), + kotlinVersions = listOf("1.9.10", "1.8.20", "1.7.20", "1.6.21", "1.5.31"), ) + BuildVersions.permutations( gradleVersions = listOf(*ifExhaustive("7.0", "6.1.1")), kotlinVersions = listOf(*ifExhaustive( "1.8.0", "1.7.0", "1.6.0", "1.5.0")) @@ -61,6 +61,7 @@ internal object TestedVersions { "1.8.20" to "18.2.0-pre.546", "1.9.0" to "18.2.0-pre.597", "1.9.10" to "18.2.0-pre.597", + "1.9.20-RC2" to "18.2.0-pre.635", ) } diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/WasmGradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/WasmGradleIntegrationTest.kt index aa3a2278ce..4280459c76 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/WasmGradleIntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/WasmGradleIntegrationTest.kt @@ -20,7 +20,8 @@ internal class WasmTestedVersionsArgumentsProvider : AllSupportedTestedVersionsA override fun provideArguments(context: ExtensionContext?): Stream { return super.provideArguments(context).filter { val buildVersions = it.get().single() as BuildVersions - buildVersions.kotlinVersion >= "1.8.20" // 1.8.20 is the first public version that can be tested with wasm + buildVersions.kotlinVersion >= "1.8.20" && // 1.8.20 is the first public version that can be tested with wasm + buildVersions.kotlinVersion <= "1.9.10"// in 1.9.20 wasm target was split into `wasm-js` and `wasm-wasi` } } } diff --git a/integration-tests/maven/projects/it-maven/pom.xml b/integration-tests/maven/projects/it-maven/pom.xml index c426fb3605..3e20bf5395 100644 --- a/integration-tests/maven/projects/it-maven/pom.xml +++ b/integration-tests/maven/projects/it-maven/pom.xml @@ -11,7 +11,7 @@ 1.0-SNAPSHOT - 1.9.10 + 1.9.20-RC diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/resolve/DokkaJsResolverForModuleFactory.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/resolve/DokkaJsResolverForModuleFactory.kt index 6957bcbf03..98f9c64a0e 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/resolve/DokkaJsResolverForModuleFactory.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/resolve/DokkaJsResolverForModuleFactory.kt @@ -44,7 +44,6 @@ internal class DokkaJsResolverForModuleFactory( metadataFactories.DefaultDescriptorFactory, metadataFactories.DefaultPackageFragmentsFactory, metadataFactories.flexibleTypeDeserializer, - metadataFactories.platformDependentTypeTransformer ) } diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/resolve/DokkaKlibMetadataCommonDependencyContainer.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/resolve/DokkaKlibMetadataCommonDependencyContainer.kt index 8016683070..09f4e48a84 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/resolve/DokkaKlibMetadataCommonDependencyContainer.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/resolve/DokkaKlibMetadataCommonDependencyContainer.kt @@ -16,7 +16,6 @@ import org.jetbrains.kotlin.library.metadata.DeserializedKlibModuleOrigin import org.jetbrains.kotlin.incremental.components.LookupTracker import org.jetbrains.kotlin.library.metadata.KlibMetadataFactories import org.jetbrains.kotlin.library.KotlinLibrary -import org.jetbrains.kotlin.library.metadata.NativeTypeTransformer import org.jetbrains.kotlin.library.metadata.NullFlexibleTypeDeserializer import org.jetbrains.kotlin.library.metadata.parseModuleHeader import org.jetbrains.kotlin.name.Name @@ -107,8 +106,7 @@ internal class DokkaKlibMetadataCommonDependencyContainer( KlibMetadataModuleDescriptorFactoryImpl( MetadataFactories.DefaultDescriptorFactory, MetadataFactories.DefaultPackageFragmentsFactory, - MetadataFactories.flexibleTypeDeserializer, - MetadataFactories.platformDependentTypeTransformer + MetadataFactories.flexibleTypeDeserializer ) } @@ -138,6 +136,5 @@ internal class DokkaKlibMetadataCommonDependencyContainer( private val MetadataFactories = KlibMetadataFactories( { DefaultBuiltIns.Instance }, - NullFlexibleTypeDeserializer, - NativeTypeTransformer() + NullFlexibleTypeDeserializer ) From 84e48b516500433332e9279237cd139f7836ca94 Mon Sep 17 00:00:00 2001 From: Vadim Mishenev Date: Mon, 6 Nov 2023 14:31:22 +0200 Subject: [PATCH 2/3] Update Kotlin to 1.9.20 (#3319) * Update compiler and KGP to 1.9.20 * Update integration tests --- gradle/libs.versions.toml | 4 ++-- .../gradle/projects/it-android-0/gradle.properties | 2 +- .../gradle/projects/it-basic-groovy/gradle.properties | 2 +- integration-tests/gradle/projects/it-basic/build.gradle.kts | 2 +- integration-tests/gradle/projects/it-basic/gradle.properties | 2 +- .../gradle/projects/it-collector-0/gradle.properties | 2 +- .../gradle/projects/it-configuration/build.gradle.kts | 2 +- .../gradle/projects/it-configuration/gradle.properties | 2 +- .../gradle/projects/it-js-ir-0/gradle.properties | 2 +- .../gradle/projects/it-multimodule-0/gradle.properties | 2 +- .../gradle/projects/it-multimodule-1/gradle.properties | 2 +- .../projects/it-multimodule-versioning-0/gradle.properties | 2 +- .../gradle/projects/it-multiplatform-0/gradle.properties | 2 +- .../it-sequential-tasks-execution-stress/gradle.properties | 2 +- .../gradle/projects/it-wasm-basic/gradle.properties | 2 +- .../jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt | 2 +- .../kotlin/org/jetbrains/dokka/it/gradle/TestedVersions.kt | 4 ++-- integration-tests/maven/projects/it-maven/pom.xml | 2 +- 18 files changed, 20 insertions(+), 20 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 034c09cb1f..ac9c0440b1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] -gradlePlugin-kotlin = "1.9.20-RC2" +gradlePlugin-kotlin = "1.9.20" # See: https://kotlinlang.org/docs/gradle-configure-project.html#apply-the-plugin gradlePlugin-android = "4.2.2" gradlePlugin-dokka = "1.9.10" @@ -10,7 +10,7 @@ kotlinx-collections-immutable = "0.3.6" kotlinx-bcv = "0.13.2" ## Analysis -kotlin-compiler = "1.9.20-RC2" +kotlin-compiler = "1.9.20" kotlin-compiler-k2 = "2.0.0-dev-5387" # MUST match the version of the intellij platform used in the kotlin compiler, diff --git a/integration-tests/gradle/projects/it-android-0/gradle.properties b/integration-tests/gradle/projects/it-android-0/gradle.properties index 6f34e9b0f3..286fe3c342 100644 --- a/integration-tests/gradle/projects/it-android-0/gradle.properties +++ b/integration-tests/gradle/projects/it-android-0/gradle.properties @@ -2,6 +2,6 @@ # Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. # -dokka_it_kotlin_version=1.9.10 +dokka_it_kotlin_version=1.9.20 dokka_it_android_gradle_plugin_version=4.2.2 android.useAndroidX=true diff --git a/integration-tests/gradle/projects/it-basic-groovy/gradle.properties b/integration-tests/gradle/projects/it-basic-groovy/gradle.properties index 1e2686effb..5904fc210f 100644 --- a/integration-tests/gradle/projects/it-basic-groovy/gradle.properties +++ b/integration-tests/gradle/projects/it-basic-groovy/gradle.properties @@ -2,4 +2,4 @@ # Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. # -dokka_it_kotlin_version=1.9.10 +dokka_it_kotlin_version=1.9.20 diff --git a/integration-tests/gradle/projects/it-basic/build.gradle.kts b/integration-tests/gradle/projects/it-basic/build.gradle.kts index 5cb354f4a0..c30e0402a0 100644 --- a/integration-tests/gradle/projects/it-basic/build.gradle.kts +++ b/integration-tests/gradle/projects/it-basic/build.gradle.kts @@ -20,7 +20,7 @@ buildscript { } } -version = "1.9.10-SNAPSHOT" +version = "1.9.20-SNAPSHOT" apply(from = "../template.root.gradle.kts") diff --git a/integration-tests/gradle/projects/it-basic/gradle.properties b/integration-tests/gradle/projects/it-basic/gradle.properties index 1e2686effb..5904fc210f 100644 --- a/integration-tests/gradle/projects/it-basic/gradle.properties +++ b/integration-tests/gradle/projects/it-basic/gradle.properties @@ -2,4 +2,4 @@ # Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. # -dokka_it_kotlin_version=1.9.10 +dokka_it_kotlin_version=1.9.20 diff --git a/integration-tests/gradle/projects/it-collector-0/gradle.properties b/integration-tests/gradle/projects/it-collector-0/gradle.properties index 1e2686effb..5904fc210f 100644 --- a/integration-tests/gradle/projects/it-collector-0/gradle.properties +++ b/integration-tests/gradle/projects/it-collector-0/gradle.properties @@ -2,4 +2,4 @@ # Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. # -dokka_it_kotlin_version=1.9.10 +dokka_it_kotlin_version=1.9.20 diff --git a/integration-tests/gradle/projects/it-configuration/build.gradle.kts b/integration-tests/gradle/projects/it-configuration/build.gradle.kts index 76e3f6512a..736202bb3b 100644 --- a/integration-tests/gradle/projects/it-configuration/build.gradle.kts +++ b/integration-tests/gradle/projects/it-configuration/build.gradle.kts @@ -16,7 +16,7 @@ buildscript { } } -version = "1.9.10-SNAPSHOT" +version = "1.9.20-SNAPSHOT" apply(from = "../template.root.gradle.kts") diff --git a/integration-tests/gradle/projects/it-configuration/gradle.properties b/integration-tests/gradle/projects/it-configuration/gradle.properties index 36aa0558dd..f958d9e3f3 100644 --- a/integration-tests/gradle/projects/it-configuration/gradle.properties +++ b/integration-tests/gradle/projects/it-configuration/gradle.properties @@ -2,6 +2,6 @@ # Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. # -dokka_it_kotlin_version=1.9.10 +dokka_it_kotlin_version=1.9.20 fail_on_warning=false report_undocumented=false diff --git a/integration-tests/gradle/projects/it-js-ir-0/gradle.properties b/integration-tests/gradle/projects/it-js-ir-0/gradle.properties index 63c36faeea..a7b64215c1 100644 --- a/integration-tests/gradle/projects/it-js-ir-0/gradle.properties +++ b/integration-tests/gradle/projects/it-js-ir-0/gradle.properties @@ -2,5 +2,5 @@ # Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. # -dokka_it_kotlin_version=1.9.10 +dokka_it_kotlin_version=1.9.20 react_version=18.2.0-pre.467 diff --git a/integration-tests/gradle/projects/it-multimodule-0/gradle.properties b/integration-tests/gradle/projects/it-multimodule-0/gradle.properties index 1e2686effb..5904fc210f 100644 --- a/integration-tests/gradle/projects/it-multimodule-0/gradle.properties +++ b/integration-tests/gradle/projects/it-multimodule-0/gradle.properties @@ -2,4 +2,4 @@ # Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. # -dokka_it_kotlin_version=1.9.10 +dokka_it_kotlin_version=1.9.20 diff --git a/integration-tests/gradle/projects/it-multimodule-1/gradle.properties b/integration-tests/gradle/projects/it-multimodule-1/gradle.properties index 1e2686effb..5904fc210f 100644 --- a/integration-tests/gradle/projects/it-multimodule-1/gradle.properties +++ b/integration-tests/gradle/projects/it-multimodule-1/gradle.properties @@ -2,4 +2,4 @@ # Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. # -dokka_it_kotlin_version=1.9.10 +dokka_it_kotlin_version=1.9.20 diff --git a/integration-tests/gradle/projects/it-multimodule-versioning-0/gradle.properties b/integration-tests/gradle/projects/it-multimodule-versioning-0/gradle.properties index 504f59b0c3..a8c5975370 100644 --- a/integration-tests/gradle/projects/it-multimodule-versioning-0/gradle.properties +++ b/integration-tests/gradle/projects/it-multimodule-versioning-0/gradle.properties @@ -2,5 +2,5 @@ # Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. # -dokka_it_kotlin_version=1.9.10 +dokka_it_kotlin_version=1.9.20 diff --git a/integration-tests/gradle/projects/it-multiplatform-0/gradle.properties b/integration-tests/gradle/projects/it-multiplatform-0/gradle.properties index 1e2686effb..5904fc210f 100644 --- a/integration-tests/gradle/projects/it-multiplatform-0/gradle.properties +++ b/integration-tests/gradle/projects/it-multiplatform-0/gradle.properties @@ -2,4 +2,4 @@ # Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. # -dokka_it_kotlin_version=1.9.10 +dokka_it_kotlin_version=1.9.20 diff --git a/integration-tests/gradle/projects/it-sequential-tasks-execution-stress/gradle.properties b/integration-tests/gradle/projects/it-sequential-tasks-execution-stress/gradle.properties index 713c80d685..c49881b923 100644 --- a/integration-tests/gradle/projects/it-sequential-tasks-execution-stress/gradle.properties +++ b/integration-tests/gradle/projects/it-sequential-tasks-execution-stress/gradle.properties @@ -2,5 +2,5 @@ # Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. # -dokka_it_kotlin_version=1.9.10 +dokka_it_kotlin_version=1.9.20 task_number=100 diff --git a/integration-tests/gradle/projects/it-wasm-basic/gradle.properties b/integration-tests/gradle/projects/it-wasm-basic/gradle.properties index 1e2686effb..5904fc210f 100644 --- a/integration-tests/gradle/projects/it-wasm-basic/gradle.properties +++ b/integration-tests/gradle/projects/it-wasm-basic/gradle.properties @@ -2,4 +2,4 @@ # Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. # -dokka_it_kotlin_version=1.9.10 +dokka_it_kotlin_version=1.9.20 diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt index a23fb41037..f2c1de0e0f 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt @@ -158,7 +158,7 @@ class BasicGradleIntegrationTest : AbstractGradleIntegrationTest() { val indexFile = File(this, "index.html") assertTrue(indexFile.isFile, "Missing index.html") assertTrue( - """Basic Project 1.9.10-SNAPSHOT API """ in indexFile.readText(), + """Basic Project 1.9.20-SNAPSHOT API """ in indexFile.readText(), "Header with version number not present in index.html" ) diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/TestedVersions.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/TestedVersions.kt index e4634c0911..7c3ea4dfaf 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/TestedVersions.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/TestedVersions.kt @@ -14,7 +14,7 @@ internal open class AllSupportedTestedVersionsArgumentsProvider : TestedVersions internal object TestedVersions { - val LATEST = BuildVersions("7.6.2", "1.9.20-RC2") + val LATEST = BuildVersions("7.6.2", "1.9.20") /** * All supported Gradle/Kotlin versions, including [LATEST] @@ -61,7 +61,7 @@ internal object TestedVersions { "1.8.20" to "18.2.0-pre.546", "1.9.0" to "18.2.0-pre.597", "1.9.10" to "18.2.0-pre.597", - "1.9.20-RC2" to "18.2.0-pre.635", + "1.9.20" to "18.2.0-pre.635", ) } diff --git a/integration-tests/maven/projects/it-maven/pom.xml b/integration-tests/maven/projects/it-maven/pom.xml index 3e20bf5395..6246e27abf 100644 --- a/integration-tests/maven/projects/it-maven/pom.xml +++ b/integration-tests/maven/projects/it-maven/pom.xml @@ -11,7 +11,7 @@ 1.0-SNAPSHOT - 1.9.20-RC + 1.9.20 From 64cce58f73f908909ba60da6005d7abb2572b2f0 Mon Sep 17 00:00:00 2001 From: Oleg Yukhnevich Date: Tue, 7 Nov 2023 15:27:34 +0200 Subject: [PATCH 3/3] Add the link to GitHub repo to the header if there are source links defined (#3235) * Use URL from base plugin configuration * Add integration test for the multi-module project that the homepage link exists everywhere --- .../it-multimodule-0/moduleA/build.gradle.kts | 10 ++ .../it/gradle/MultiModule0IntegrationTest.kt | 15 +++ plugins/base/api/base.api | 11 +- .../src/main/kotlin/DokkaBaseConfiguration.kt | 3 +- .../renderers/html/htmlPreprocessors.kt | 1 + .../DefaultTemplateModelFactory.kt | 24 ++++- .../main/resources/dokka/images/homepage.svg | 5 + .../src/main/resources/dokka/styles/style.css | 32 +++++- .../dokka/templates/includes/header.ftl | 3 + .../test/kotlin/renderers/html/HeaderTest.kt | 102 ++++++++++++++++++ 10 files changed, 195 insertions(+), 11 deletions(-) create mode 100644 plugins/base/src/main/resources/dokka/images/homepage.svg create mode 100644 plugins/base/src/test/kotlin/renderers/html/HeaderTest.kt diff --git a/integration-tests/gradle/projects/it-multimodule-0/moduleA/build.gradle.kts b/integration-tests/gradle/projects/it-multimodule-0/moduleA/build.gradle.kts index 1e61f8b2b7..d24b90c50d 100644 --- a/integration-tests/gradle/projects/it-multimodule-0/moduleA/build.gradle.kts +++ b/integration-tests/gradle/projects/it-multimodule-0/moduleA/build.gradle.kts @@ -8,3 +8,13 @@ plugins { kotlin("jvm") id("org.jetbrains.dokka") } + +allprojects { + tasks.withType { + pluginsMapConfiguration.set( + mapOf( + "org.jetbrains.dokka.base.DokkaBase" to """{ "homepageLink" : "https://github.com/Kotlin/dokka/tree/master/integration-tests/gradle/projects/it-multimodule-0/" }""" + ) + ) + } +} diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/MultiModule0IntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/MultiModule0IntegrationTest.kt index 54ac3ff8ab..f4061345f0 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/MultiModule0IntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/MultiModule0IntegrationTest.kt @@ -73,6 +73,21 @@ class MultiModule0IntegrationTest : AbstractGradleIntegrationTest() { "Expected moduleC being mentioned in -modules.html" ) + val htmlsWithHomepageLink = outputDir.walkTopDown().filter { + it.isFile && it.extension == "html" && it.name != "navigation.html" + }.toList() + + assertEquals(16, htmlsWithHomepageLink.size) + + htmlsWithHomepageLink.forEach { + assertTrue( + it.readText().contains( + """https://github.com/Kotlin/dokka/tree/master/integration-tests/gradle/projects/it-multimodule-0/""" + ), + "File ${it.absolutePath} doesn't contain link to homepage" + ) + } + val gfmOutputDir = File(projectDir, "moduleA/build/dokka/gfmMultiModule") assertTrue(gfmOutputDir.isDirectory, "Missing dokka GFM output directory") diff --git a/plugins/base/api/base.api b/plugins/base/api/base.api index ae87255803..13f877e353 100644 --- a/plugins/base/api/base.api +++ b/plugins/base/api/base.api @@ -105,20 +105,22 @@ public final class org/jetbrains/dokka/base/DokkaBaseConfiguration : org/jetbrai public static final field mergeImplicitExpectActualDeclarationsDefault Z public static final field separateInheritedMembersDefault Z public fun ()V - public fun (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZLjava/io/File;)V - public synthetic fun (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZLjava/io/File;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZLjava/io/File;Ljava/lang/String;)V + public synthetic fun (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZLjava/io/File;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ljava/util/List; public final fun component2 ()Ljava/util/List; public final fun component3 ()Z public final fun component4 ()Ljava/lang/String; public final fun component5 ()Z public final fun component6 ()Ljava/io/File; - public final fun copy (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZLjava/io/File;)Lorg/jetbrains/dokka/base/DokkaBaseConfiguration; - public static synthetic fun copy$default (Lorg/jetbrains/dokka/base/DokkaBaseConfiguration;Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZLjava/io/File;ILjava/lang/Object;)Lorg/jetbrains/dokka/base/DokkaBaseConfiguration; + public final fun component7 ()Ljava/lang/String; + public final fun copy (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZLjava/io/File;Ljava/lang/String;)Lorg/jetbrains/dokka/base/DokkaBaseConfiguration; + public static synthetic fun copy$default (Lorg/jetbrains/dokka/base/DokkaBaseConfiguration;Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZLjava/io/File;Ljava/lang/String;ILjava/lang/Object;)Lorg/jetbrains/dokka/base/DokkaBaseConfiguration; public fun equals (Ljava/lang/Object;)Z public final fun getCustomAssets ()Ljava/util/List; public final fun getCustomStyleSheets ()Ljava/util/List; public final fun getFooterMessage ()Ljava/lang/String; + public final fun getHomepageLink ()Ljava/lang/String; public final fun getMergeImplicitExpectActualDeclarations ()Z public final fun getSeparateInheritedMembers ()Z public final fun getTemplatesDir ()Ljava/io/File; @@ -126,6 +128,7 @@ public final class org/jetbrains/dokka/base/DokkaBaseConfiguration : org/jetbrai public final fun setCustomAssets (Ljava/util/List;)V public final fun setCustomStyleSheets (Ljava/util/List;)V public final fun setFooterMessage (Ljava/lang/String;)V + public final fun setHomepageLink (Ljava/lang/String;)V public final fun setMergeImplicitExpectActualDeclarations (Z)V public final fun setSeparateInheritedMembers (Z)V public final fun setTemplatesDir (Ljava/io/File;)V diff --git a/plugins/base/src/main/kotlin/DokkaBaseConfiguration.kt b/plugins/base/src/main/kotlin/DokkaBaseConfiguration.kt index 1118412635..34195f6558 100644 --- a/plugins/base/src/main/kotlin/DokkaBaseConfiguration.kt +++ b/plugins/base/src/main/kotlin/DokkaBaseConfiguration.kt @@ -14,7 +14,8 @@ public data class DokkaBaseConfiguration( var separateInheritedMembers: Boolean = separateInheritedMembersDefault, var footerMessage: String = defaultFooterMessage, var mergeImplicitExpectActualDeclarations: Boolean = mergeImplicitExpectActualDeclarationsDefault, - var templatesDir: File? = defaultTemplatesDir + var templatesDir: File? = defaultTemplatesDir, + var homepageLink: String? = null, ) : ConfigurableBlock { public companion object { public val defaultFooterMessage: String = "© ${Year.now().value} Copyright" diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt index dc877605e9..dad013e232 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -111,6 +111,7 @@ public object AssetsInstaller : PageTransformer { "images/copy-successful-icon.svg", "images/theme-toggle.svg", "images/burger.svg", + "images/homepage.svg", // navigation icons "images/nav-icons/abstract-class.svg", diff --git a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt index 3883bc4aed..fe6f008904 100644 --- a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt +++ b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt @@ -86,10 +86,16 @@ public class DefaultTemplateModelFactory( return mapper } - override fun buildSharedModel(): TemplateMap = mapOf( - "footerMessage" to (configuration?.footerMessage?.takeIf { it.isNotEmpty() } - ?: DokkaBaseConfiguration.defaultFooterMessage) - ) + override fun buildSharedModel(): TemplateMap { + val mapper = mutableMapOf() + + mapper["footerMessage"] = + (configuration?.footerMessage?.takeIf(String::isNotBlank) ?: DokkaBaseConfiguration.defaultFooterMessage) + + configuration?.homepageLink?.takeIf(String::isNotBlank)?.let { mapper["homepageLink"] = it } + + return mapper + } private val DisplaySourceSet.comparableKey get() = sourceSetIDs.merged.let { it.scopeId + it.sourceSetName } @@ -107,6 +113,7 @@ public class DefaultTemplateModelFactory( rel = LinkRel.stylesheet, href = if (resource.isAbsolute) resource else "$pathToRoot$resource" ) + resource.URIExtension == "js" -> script( type = ScriptType.textJavaScript, @@ -117,6 +124,7 @@ public class DefaultTemplateModelFactory( else async = true } + resource.isImage() -> link(href = if (resource.isAbsolute) resource else "$pathToRoot$resource") else -> null } @@ -125,6 +133,7 @@ public class DefaultTemplateModelFactory( append(resourceHtml) } } + } private class PrintDirective(val generateData: () -> String) : TemplateDirectiveModel { @@ -144,7 +153,10 @@ private class PrintDirective(val generateData: () -> String) : TemplateDirective } } -private class TemplateDirective(val configuration: DokkaConfiguration, val pathToRoot: String) : TemplateDirectiveModel { +private class TemplateDirective( + val configuration: DokkaConfiguration, + val pathToRoot: String +) : TemplateDirectiveModel { override fun execute( env: Environment, params: MutableMap?, @@ -170,6 +182,7 @@ private class TemplateDirective(val configuration: DokkaConfiguration, val pathT Context(env, body) ) } + "projectName" -> { body ?: throw TemplateModelException( "No directive body $commandName command." @@ -183,6 +196,7 @@ private class TemplateDirective(val configuration: DokkaConfiguration, val pathT Context(env, body) ) } + else -> throw TemplateModelException( "The parameter $PARAM_NAME $commandName is unknown" ) diff --git a/plugins/base/src/main/resources/dokka/images/homepage.svg b/plugins/base/src/main/resources/dokka/images/homepage.svg new file mode 100644 index 0000000000..a3d7602bb8 --- /dev/null +++ b/plugins/base/src/main/resources/dokka/images/homepage.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/plugins/base/src/main/resources/dokka/styles/style.css b/plugins/base/src/main/resources/dokka/styles/style.css index 67a899a594..62b0ddbd2c 100644 --- a/plugins/base/src/main/resources/dokka/styles/style.css +++ b/plugins/base/src/main/resources/dokka/styles/style.css @@ -342,6 +342,7 @@ td:first-child { /* --- Navigation controls --- */ .navigation-controls { display: flex; + margin-left: 4px; } @media (min-width: 760px) { @@ -365,7 +366,6 @@ td:first-child { display: block; border-radius: 50%; background-color: inherit; - margin-left: 4px; padding: 0; border: none; cursor: pointer; @@ -394,6 +394,36 @@ td:first-child { } /* /--- Navigation THEME --- */ +/* --- Navigation HOMEPAGE --- */ +.navigation-controls--homepage { + height: 40px; + width: 40px; + display: block; + border-radius: 50%; + cursor: pointer; +} + +.navigation-controls--homepage a::before { + height: 100%; + width: 20px; + margin-left: 10px; + display: block; + content: ""; + background: url("../images/homepage.svg"); + background-size: 100% 100%; +} + +.navigation-controls--homepage:hover { + background: var(--white-10); +} + +@media (max-width: 759px) { + .navigation-controls--homepage { + display: none; + } +} +/* /--- Navigation HOMEPAGE --- */ + .navigation .platform-selector:not([data-active]) { color: #fff; } diff --git a/plugins/base/src/main/resources/dokka/templates/includes/header.ftl b/plugins/base/src/main/resources/dokka/templates/includes/header.ftl index d5c7a61315..d399e63354 100644 --- a/plugins/base/src/main/resources/dokka/templates/includes/header.ftl +++ b/plugins/base/src/main/resources/dokka/templates/includes/header.ftl @@ -21,6 +21,9 @@ <@source_set_selector.display/> diff --git a/plugins/base/src/test/kotlin/renderers/html/HeaderTest.kt b/plugins/base/src/test/kotlin/renderers/html/HeaderTest.kt new file mode 100644 index 0000000000..c19f965f02 --- /dev/null +++ b/plugins/base/src/test/kotlin/renderers/html/HeaderTest.kt @@ -0,0 +1,102 @@ +/* + * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package renderers.html + +import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.DokkaConfigurationImpl +import org.jetbrains.dokka.PluginConfigurationImpl +import org.jetbrains.dokka.base.DokkaBase +import org.jetbrains.dokka.base.DokkaBaseConfiguration +import org.jetbrains.dokka.base.templating.toJsonString +import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest +import org.jetbrains.dokka.pages.RootPageNode +import org.jetbrains.dokka.plugability.DokkaContext +import org.jsoup.Jsoup +import utils.TestOutputWriter +import utils.TestOutputWriterPlugin +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertNotNull +import kotlin.test.assertNull + +class HeaderTest : BaseAbstractTest() { + private val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + name = "jvm" + sourceRoots = listOf("src/jvm") + } + sourceSet { + name = "js" + sourceRoots = listOf("src/js") + } + } + } + + @Test + fun `should include homepage link if homepageLink is provided`() { + testRendering( + DokkaBaseConfiguration(homepageLink = "https://github.com/Kotlin/dokka/") + ) { _, _, writer -> + val renderedContent = navigationElement(writer) + + val sourceLinkElement = + assertNotNull(renderedContent.getElementById("homepage-link"), "Source link element not found") + val aElement = assertNotNull(sourceLinkElement.selectFirst("a")) + assertEquals("https://github.com/Kotlin/dokka/", aElement.attr("href")) + } + } + + @Test + fun `should not include homepage link by default`() { + testRendering(null) { _, _, writer -> + val renderedContent = navigationElement(writer) + assertNull(renderedContent.getElementById("homepage-link"), "Source link element found") + } + } + + private fun testRendering( + baseConfiguration: DokkaBaseConfiguration?, + block: (RootPageNode, DokkaContext, writer: TestOutputWriter) -> Unit + ) { + fun configuration(): DokkaConfigurationImpl { + baseConfiguration ?: return configuration + return configuration.copy( + pluginsConfiguration = listOf( + PluginConfigurationImpl( + DokkaBase::class.java.canonicalName, + DokkaConfiguration.SerializationFormat.JSON, + toJsonString(baseConfiguration) + ) + ) + ) + } + + val writerPlugin = TestOutputWriterPlugin() + testInline( + """ + |/src/jvm/Test.kt + |fun test() {} + |/src/js/Test.kt + |fun test() {} + """, + configuration(), + pluginOverrides = listOf(writerPlugin) + ) { + renderingStage = { node, context -> + block(node, context, writerPlugin.writer) + } + } + } + + private fun navigationElement(writer: TestOutputWriter) = + writer + .contents + .getValue("index.html") + .let(Jsoup::parse) + .select(".navigation") + .single() + +}