diff options
33 files changed, 75 insertions, 69 deletions
diff --git a/.github/workflows/preview-publish-ga.yml b/.github/workflows/preview-publish-ga.yml index 8b428d7a..2137d9d8 100644 --- a/.github/workflows/preview-publish-ga.yml +++ b/.github/workflows/preview-publish-ga.yml @@ -27,7 +27,7 @@ jobs: uses: gradle/gradle-build-action@v2 with: gradle-home-cache-cleanup: true - arguments: :integration-tests:gradle:integrationTest --tests org.jetbrains.dokka.it.gradle.kotlin.CoroutinesGradleIntegrationTest --stacktrace + arguments: :integration-tests:gradle:integrationTest --tests org.jetbrains.dokka.it.gradle.kotlin.CoroutinesGradleIntegrationTest --stacktrace "-Dorg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=500m" env: DOKKA_TEST_OUTPUT_PATH: /home/runner/work/dokka/coroutines - name: Copy files to GitHub Actions Artifacts @@ -56,7 +56,7 @@ jobs: uses: gradle/gradle-build-action@v2 with: gradle-home-cache-cleanup: true - arguments: :integration-tests:gradle:integrationTest --tests org.jetbrains.dokka.it.gradle.kotlin.SerializationGradleIntegrationTest --stacktrace + arguments: :integration-tests:gradle:integrationTest --tests org.jetbrains.dokka.it.gradle.kotlin.SerializationGradleIntegrationTest --stacktrace "-Dorg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=500m" env: DOKKA_TEST_OUTPUT_PATH: /home/runner/work/dokka/serialization - name: Copy files to GitHub Actions Artifacts diff --git a/.github/workflows/preview-publish-web-s3.yml b/.github/workflows/preview-publish-web-s3.yml index a9d34e28..15bf9477 100644 --- a/.github/workflows/preview-publish-web-s3.yml +++ b/.github/workflows/preview-publish-web-s3.yml @@ -24,7 +24,7 @@ jobs: uses: gradle/gradle-build-action@v2 with: gradle-home-cache-cleanup: true - arguments: :integration-tests:gradle:integrationTest --tests org.jetbrains.dokka.it.gradle.kotlin.CoroutinesGradleIntegrationTest --stacktrace + arguments: :integration-tests:gradle:integrationTest --tests org.jetbrains.dokka.it.gradle.kotlin.CoroutinesGradleIntegrationTest --stacktrace "-Dorg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=500m" env: DOKKA_TEST_OUTPUT_PATH: /home/runner/work/dokka/coroutines - name: Configure AWS credentials for S3 access @@ -55,7 +55,7 @@ jobs: uses: gradle/gradle-build-action@v2 with: gradle-home-cache-cleanup: true - arguments: :integration-tests:gradle:integrationTest --tests org.jetbrains.dokka.it.gradle.kotlin.SerializationGradleIntegrationTest --stacktrace + arguments: :integration-tests:gradle:integrationTest --tests org.jetbrains.dokka.it.gradle.kotlin.SerializationGradleIntegrationTest --stacktrace "-Dorg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=500m" env: DOKKA_TEST_OUTPUT_PATH: /home/runner/work/dokka/serialization - name: Configure AWS credentials for S3 access diff --git a/.github/workflows/tests-smoke.yml b/.github/workflows/tests-smoke.yml index 96ab0196..1177c111 100644 --- a/.github/workflows/tests-smoke.yml +++ b/.github/workflows/tests-smoke.yml @@ -29,7 +29,7 @@ jobs: if: matrix.os == 'windows-latest' # Running tests with the Gradle daemon on windows agents leads to some very strange # JVM crashes for some reason. Most likely a problem of Gradle/GitHub/Windows server - run: ./gradlew clean test --stacktrace --no-daemon + run: ./gradlew clean test --stacktrace --no-daemon --no-parallel "-Dorg.gradle.jvmargs=-Xmx1g -XX:MaxMetaspaceSize=500m" - name: Run tests under Ubuntu if: matrix.os != 'windows-latest' run: ./gradlew clean test --stacktrace diff --git a/.github/workflows/tests-thorough.yml b/.github/workflows/tests-thorough.yml index 6e54f9a3..7684277e 100644 --- a/.github/workflows/tests-thorough.yml +++ b/.github/workflows/tests-thorough.yml @@ -30,7 +30,7 @@ jobs: if: matrix.os == 'windows-latest' # Running tests with the Gradle daemon on windows agents leads to some very strange # JVM crashes for some reason. Most likely a problem of Gradle/GitHub/Windows server - run: ./gradlew clean test --stacktrace --no-daemon + run: ./gradlew clean test --stacktrace --no-daemon --no-parallel "-Dorg.gradle.jvmargs=-Xmx1g -XX:MaxMetaspaceSize=500m" - name: Run tests under Ubuntu/Macos if: matrix.os != 'windows-latest' run: ./gradlew clean test --stacktrace diff --git a/core/api/core.api b/core/api/core.api index d66c5d9e..52a612d5 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -4687,7 +4687,7 @@ public final class org/jetbrains/dokka/utilities/ServiceLookupException : java/l public final class org/jetbrains/dokka/utilities/TypeReference { public static final field Companion Lorg/jetbrains/dokka/utilities/TypeReference$Companion; - public synthetic fun <init> (Lcom/fasterxml/jackson/core/type/TypeReference;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun <init> (Lcom/fasterxml/jackson/core/type/TypeReference;)V } public final class org/jetbrains/dokka/utilities/TypeReference$Companion { diff --git a/core/src/main/kotlin/utilities/json.kt b/core/src/main/kotlin/utilities/json.kt index 61736a99..eb666d31 100644 --- a/core/src/main/kotlin/utilities/json.kt +++ b/core/src/main/kotlin/utilities/json.kt @@ -20,10 +20,11 @@ private val objectMapper = run { } @PublishedApi -internal class TypeReference<T> private constructor( +internal class TypeReference<T> @PublishedApi internal constructor( internal val jackson: JacksonTypeReference<T> ) { companion object { + @PublishedApi internal inline operator fun <reified T> invoke(): TypeReference<T> = TypeReference(jacksonTypeRef()) } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index db3d79af..9bdb7901 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] -gradlePlugin-kotlin = "1.8.10" -gradlePlugin-android = "4.0.1" +gradlePlugin-kotlin = "1.8.20" +gradlePlugin-android = "4.1.3" gradlePlugin-dokka = "1.7.10" kotlinx-coroutines = "1.6.3" diff --git a/integration-tests/gradle/projects/it-android-0/gradle.properties b/integration-tests/gradle/projects/it-android-0/gradle.properties index 8f0204a1..b139fef9 100644 --- a/integration-tests/gradle/projects/it-android-0/gradle.properties +++ b/integration-tests/gradle/projects/it-android-0/gradle.properties @@ -1,3 +1,3 @@ dokka_it_kotlin_version=1.8.10 -dokka_it_android_gradle_plugin_version=4.0.0 +dokka_it_android_gradle_plugin_version=4.1.3 android.useAndroidX=true 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 ec24e720..4a58526b 100644 --- a/integration-tests/gradle/projects/it-multiplatform-0/build.gradle.kts +++ b/integration-tests/gradle/projects/it-multiplatform-0/build.gradle.kts @@ -25,7 +25,12 @@ kotlin { } named("commonMain") { dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9") + if (properties["dokka_it_kotlin_version"] in listOf("1.4.32", "1.5.31")) + // otherwise for a modern versin of coroutines: + // Failed to resolve Kotlin library: project/build/kotlinSourceSetMetadata/commonMain/org.jetbrains.kotlinx-kotlinx-coroutines-core/org.jetbrains.kotlinx-kotlinx-coroutines-core-commonMain.klib + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9") + else + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") } } } diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/SequentialTasksExecutionStressTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/SequentialTasksExecutionStressTest.kt index 32ed27f4..62eea6bf 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/SequentialTasksExecutionStressTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/SequentialTasksExecutionStressTest.kt @@ -37,7 +37,7 @@ class SequentialTasksExecutionStressTest(override val versions: BuildVersions) : "--info", "--stacktrace", "-Ptask_number=100", - jvmArgs = listOf("-Xmx1G", "-XX:MaxMetaspaceSize=350m") + jvmArgs = listOf("-Xmx1G", "-XX:MaxMetaspaceSize=400m") ).buildRelaxed() assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":runTasks")).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 82dc79e2..0b56d6ef 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 @@ -2,7 +2,7 @@ package org.jetbrains.dokka.it.gradle internal object TestedVersions { - val LATEST = BuildVersions("7.4.2", "1.8.10") + val LATEST = BuildVersions("7.4.2", "1.8.20") /** * All supported Gradle/Kotlin versions, including [LATEST] @@ -46,5 +46,6 @@ internal object TestedVersions { "1.7.20" to "18.2.0-pre.391", "1.8.0" to "18.2.0-pre.467", "1.8.10" to "18.2.0-pre.490", + "1.8.20" to "18.2.0-pre.546" ) } diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/kotlin/CoroutinesGradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/kotlin/CoroutinesGradleIntegrationTest.kt index 65055623..24b2378d 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/kotlin/CoroutinesGradleIntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/kotlin/CoroutinesGradleIntegrationTest.kt @@ -33,7 +33,10 @@ class CoroutinesGradleIntegrationTest(override val versions: BuildVersions) : Ab @Test fun execute() { - val result = createGradleRunner(":dokkaHtmlMultiModule", "-i", "-s").buildRelaxed() + val result = createGradleRunner( + ":dokkaHtmlMultiModule", "-i", "-s", + jvmArgs = listOf("-Xmx2G", "-XX:MaxMetaspaceSize=500m") + ).buildRelaxed() assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":dokkaHtmlMultiModule")).outcome) diff --git a/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt index 84efac93..43cc575b 100644 --- a/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt +++ b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt @@ -28,7 +28,7 @@ abstract class AbstractGradleIntegrationTest : AbstractIntegrationTest() { fun createGradleRunner( vararg arguments: String, - jvmArgs: List<String> = listOf("-Xmx4G", "-XX:MaxMetaspaceSize=2G") + jvmArgs: List<String> = listOf("-Xmx2G", "-XX:MaxMetaspaceSize=1G") ): GradleRunner { return GradleRunner.create() .withProjectDir(projectDir) diff --git a/plugins/base/api/base.api b/plugins/base/api/base.api index 5e36f375..7875800e 100644 --- a/plugins/base/api/base.api +++ b/plugins/base/api/base.api @@ -1109,7 +1109,7 @@ public abstract class org/jetbrains/dokka/base/templating/SubstitutionCommand : public final class org/jetbrains/dokka/base/templating/TypeReference { public static final field Companion Lorg/jetbrains/dokka/base/templating/TypeReference$Companion; - public synthetic fun <init> (Lcom/fasterxml/jackson/core/type/TypeReference;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun <init> (Lcom/fasterxml/jackson/core/type/TypeReference;)V } public final class org/jetbrains/dokka/base/templating/TypeReference$Companion { diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index 45a735c6..67e9407f 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -102,9 +102,9 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog } } - private fun <T : DClasslike> classlikeSignature(c: T): List<ContentNode> { + private fun classlikeSignature(c: DClasslike): List<ContentNode> { @Suppress("UNCHECKED_CAST") - val typeAliasUnderlyingType = (c as? WithExtraProperties<out DClasslike>) + val typeAliasUnderlyingType = (c as? WithExtraProperties<DClasslike>) ?.extra ?.get(ActualTypealias) ?.underlyingType diff --git a/plugins/base/src/main/kotlin/templating/jsonMapperForPlugins.kt b/plugins/base/src/main/kotlin/templating/jsonMapperForPlugins.kt index 98cabd72..903063d3 100644 --- a/plugins/base/src/main/kotlin/templating/jsonMapperForPlugins.kt +++ b/plugins/base/src/main/kotlin/templating/jsonMapperForPlugins.kt @@ -11,6 +11,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.jetbrains.dokka.base.DokkaBase import java.io.File +// TODO [beresnev] try to get rid of this copy-paste in #2933 // THIS IS COPIED FROM BASE SINCE IT NEEDS TO BE INSTANTIATED ON THE SAME CLASS LOADER AS PLUGINS private val objectMapper = run { @@ -26,10 +27,11 @@ private val objectMapper = run { } @PublishedApi -internal class TypeReference<T> private constructor( +internal class TypeReference<T> @PublishedApi internal constructor( internal val jackson: com.fasterxml.jackson.core.type.TypeReference<T> ) { companion object { + @PublishedApi internal inline operator fun <reified T> invoke(): TypeReference<T> = TypeReference(jacksonTypeRef()) } } @@ -53,4 +55,4 @@ private object FileSerializer : StdScalarSerializer<File>(File::class.java) { private class PluginTypeFactory: TypeFactory(null) { override fun findClass(className: String): Class<out Any>? = Class.forName(className, true, DokkaBase::class.java.classLoader) ?: super.findClass(className) -}
\ No newline at end of file +} diff --git a/plugins/base/src/main/kotlin/transformers/documentables/utils.kt b/plugins/base/src/main/kotlin/transformers/documentables/utils.kt index 079cebea..379855ea 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/utils.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/utils.kt @@ -5,11 +5,11 @@ import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.ExceptionInSupertypes import org.jetbrains.dokka.model.properties.WithExtraProperties -val <T : WithExtraProperties<out Documentable>> T.isException: Boolean +val <T : Documentable> WithExtraProperties<T>.isException: Boolean get() = extra[ExceptionInSupertypes] != null -val <T> T.deprecatedAnnotation where T : WithExtraProperties<out Documentable> +val <T : Documentable> WithExtraProperties<T>.deprecatedAnnotation get() = extra[Annotations]?.let { annotations -> annotations.directAnnotations.values.flatten().firstOrNull { it.isDeprecated() @@ -20,7 +20,7 @@ val <T> T.deprecatedAnnotation where T : WithExtraProperties<out Documentable> * @return true if [T] has [kotlin.Deprecated] or [java.lang.Deprecated] * annotation for **any** source set */ -fun <T> T.isDeprecated() where T : WithExtraProperties<out Documentable> = deprecatedAnnotation != null +fun <T : Documentable> WithExtraProperties<T>.isDeprecated() = deprecatedAnnotation != null /** * @return true for [kotlin.Deprecated] and [java.lang.Deprecated] diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 98cf6ab6..1abd3441 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -724,7 +724,7 @@ private val divergentDocumentableComparator = @Suppress("UNCHECKED_CAST") private fun <T : Documentable> T.nameAfterClash(): String = - ((this as? WithExtraProperties<out Documentable>)?.extra?.get(DriClashAwareName)?.value ?: name).orEmpty() + ((this as? WithExtraProperties<Documentable>)?.extra?.get(DriClashAwareName)?.value ?: name).orEmpty() @Suppress("UNCHECKED_CAST") internal inline fun <reified T : TagWrapper> GroupedTags.withTypeUnnamed(): SourceSetDependent<T> = diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt index 39e2525e..e6e0e037 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt @@ -119,9 +119,10 @@ object DeprecatedPageCreator : PageTransformer { override fun invoke(input: RootPageNode): RootPageNode { val elements = HashMap<DeprecatedPageSection, MutableSet<DeprecatedNode>>().apply { - fun <T> T.putAs(deprecatedPageSection: DeprecatedPageSection) where + fun <T, V> T.putAs(deprecatedPageSection: DeprecatedPageSection) where T : NavigableJavadocNode, - T : WithJavadocExtra<out Documentable> { + V : Documentable, + T : WithJavadocExtra<V> { val deprecatedNode = DeprecatedNode( listOfNotNull( getDRI().packageName?.takeUnless { it.isBlank() }, @@ -159,7 +160,7 @@ object DeprecatedPageCreator : PageTransformer { it.takeIf { it.isDeprecated() }?.putAs(DeprecatedPageSection.DeprecatedEnumConstants) } node.takeIf { it.isDeprecated() }?.putAs( - if ((node as? WithJavadocExtra<out Documentable>)?.isException == true) DeprecatedPageSection.DeprecatedExceptions + if ((node as? WithJavadocExtra<*>)?.isException == true) DeprecatedPageSection.DeprecatedExceptions else when (node.kind) { "enum" -> DeprecatedPageSection.DeprecatedEnums "interface" -> DeprecatedPageSection.DeprecatedInterfaces diff --git a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt index 5f98494e..4df0d3c5 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt @@ -482,7 +482,7 @@ internal fun ClassKind.asJava(): ClassKind { } } -private fun PropertyContainer<out Documentable>.mergeAdditionalModifiers(second: SourceSetDependent<Set<ExtraModifiers>>) = +private fun <T : Documentable> PropertyContainer<T>.mergeAdditionalModifiers(second: SourceSetDependent<Set<ExtraModifiers>>) = this[AdditionalModifiers]?.squash(AdditionalModifiers(second)) ?: AdditionalModifiers(second) private fun AdditionalModifiers.squash(second: AdditionalModifiers) = @@ -494,4 +494,4 @@ internal fun ClassId.classNames(): String = private fun DProperty.hasModifier(modifier: ExtraModifiers.KotlinOnlyModifiers): Boolean = extra[AdditionalModifiers] ?.content - ?.any { (_, modifiers) -> modifier in modifiers } == true
\ No newline at end of file + ?.any { (_, modifiers) -> modifier in modifiers } == true diff --git a/plugins/kotlin-as-java/src/main/kotlin/jvmField.kt b/plugins/kotlin-as-java/src/main/kotlin/jvmField.kt index b421bd3d..fea78abb 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/jvmField.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/jvmField.kt @@ -5,8 +5,8 @@ import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.kotlin.util.firstNotNullResult -internal fun WithExtraProperties<out Documentable>.jvmField(): Annotations.Annotation? = +internal fun <T : Documentable> WithExtraProperties<T>.jvmField(): Annotations.Annotation? = extra[Annotations]?.directAnnotations?.entries?.firstNotNullResult { (_, annotations) -> annotations.jvmFieldAnnotation() } internal fun List<Annotations.Annotation>.jvmFieldAnnotation(): Annotations.Annotation? = - firstOrNull { it.dri.packageName == "kotlin.jvm" && it.dri.classNames == "JvmField" }
\ No newline at end of file + firstOrNull { it.dri.packageName == "kotlin.jvm" && it.dri.classNames == "JvmField" } diff --git a/plugins/kotlin-as-java/src/main/kotlin/jvmName.kt b/plugins/kotlin-as-java/src/main/kotlin/jvmName.kt index 44271f2c..600318e5 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/jvmName.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/jvmName.kt @@ -7,13 +7,13 @@ import org.jetbrains.dokka.model.isJvmName import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.kotlin.util.firstNotNullResult -internal fun WithExtraProperties<out Documentable>.directlyAnnotatedJvmName(): Annotations.Annotation? = +internal fun <T : Documentable> WithExtraProperties<T>.directlyAnnotatedJvmName(): Annotations.Annotation? = extra[Annotations]?.directAnnotations?.entries?.firstNotNullResult { (_, annotations)-> annotations.jvmNameAnnotation() } -internal fun WithExtraProperties<out Documentable>.fileLevelJvmName(): Annotations.Annotation? = +internal fun <T : Documentable> WithExtraProperties<T>.fileLevelJvmName(): Annotations.Annotation? = extra[Annotations]?.fileLevelAnnotations?.entries?.firstNotNullResult { (_, annotations) -> annotations.jvmNameAnnotation() } internal fun List<Annotations.Annotation>.jvmNameAnnotation(): Annotations.Annotation? = firstOrNull { it.isJvmName() } -internal fun Annotations.Annotation.jvmNameAsString(): String? = (params["name"] as? StringValue)?.value
\ No newline at end of file +internal fun Annotations.Annotation.jvmNameAsString(): String? = (params["name"] as? StringValue)?.value diff --git a/plugins/kotlin-as-java/src/main/kotlin/jvmOverloads.kt b/plugins/kotlin-as-java/src/main/kotlin/jvmOverloads.kt index d8e4f67c..9913d017 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/jvmOverloads.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/jvmOverloads.kt @@ -4,11 +4,11 @@ import org.jetbrains.dokka.model.Annotations import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.properties.WithExtraProperties -internal fun WithExtraProperties<out Documentable>.hasJvmOverloads(): Boolean { +internal fun <T : Documentable> WithExtraProperties<T>.hasJvmOverloads(): Boolean { return extra[Annotations] ?.directAnnotations ?.entries ?.any { (_, annotations) -> annotations.any { it.dri.packageName == "kotlin.jvm" && it.dri.classNames == "JvmOverloads" } } == true -}
\ No newline at end of file +} diff --git a/plugins/kotlin-as-java/src/main/kotlin/jvmStatic.kt b/plugins/kotlin-as-java/src/main/kotlin/jvmStatic.kt index 10372ac9..50ea7795 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/jvmStatic.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/jvmStatic.kt @@ -5,8 +5,8 @@ import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.kotlin.util.firstNotNullResult -internal fun WithExtraProperties<out Documentable>.jvmStatic(): Annotations.Annotation? = +internal fun <T : Documentable> WithExtraProperties<T>.jvmStatic(): Annotations.Annotation? = extra[Annotations]?.directAnnotations?.entries?.firstNotNullResult { (_, annotations) -> annotations.jvmStaticAnnotation() } internal fun List<Annotations.Annotation>.jvmStaticAnnotation(): Annotations.Annotation? = - firstOrNull { it.dri.packageName == "kotlin.jvm" && it.dri.classNames == "JvmStatic" }
\ No newline at end of file + firstOrNull { it.dri.packageName == "kotlin.jvm" && it.dri.classNames == "JvmStatic" } diff --git a/plugins/kotlin-as-java/src/main/kotlin/jvmSynthetic.kt b/plugins/kotlin-as-java/src/main/kotlin/jvmSynthetic.kt index e866ec8b..9629db0c 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/jvmSynthetic.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/jvmSynthetic.kt @@ -1,14 +1,13 @@ package org.jetbrains.dokka.kotlinAsJava import org.jetbrains.dokka.model.Annotations -import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.properties.WithExtraProperties -internal fun WithExtraProperties<out Documentable>.hasJvmSynthetic(): Boolean { +internal fun <T : org.jetbrains.dokka.model.AnnotationTarget> WithExtraProperties<T>.hasJvmSynthetic(): Boolean { return extra[Annotations] ?.directAnnotations ?.entries ?.any { (_, annotations) -> annotations.any { it.dri.packageName == "kotlin.jvm" && it.dri.classNames == "JvmSynthetic" } } == true -}
\ No newline at end of file +} diff --git a/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt index c928ea67..4c35def7 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt @@ -11,12 +11,12 @@ data class Name(val fqName: String) { } class JvmNameProvider { - fun <T> nameFor(entry: T): String where T : Documentable, T : WithExtraProperties<out Documentable> = + fun <T> nameFor(entry: T): String where T : Documentable, T : WithExtraProperties<T> = entry.directlyAnnotatedJvmName()?.jvmNameAsString() ?: entry.name ?: throw IllegalStateException("Failed to provide a name for ${entry.javaClass.canonicalName}") - fun <T> nameForSyntheticClass(entry: T): Name where T : WithSources, T : WithExtraProperties<out Documentable>, T : Documentable { + fun <T> nameForSyntheticClass(entry: T): Name where T : WithSources, T : WithExtraProperties<T>, T : Documentable { val name: String = (entry.fileLevelJvmName()?.params?.get("name") as? StringValue)?.value ?: (entry.sources.entries.first().value.path.split("/").last().split(".").first().capitalize() + "Kt") return Name("${entry.dri.packageName}.$name") diff --git a/runners/gradle-plugin/api/gradle-plugin.api b/runners/gradle-plugin/api/gradle-plugin.api index fead39f9..b082f22b 100644 --- a/runners/gradle-plugin/api/gradle-plugin.api +++ b/runners/gradle-plugin/api/gradle-plugin.api @@ -131,6 +131,7 @@ public class org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder : org/jetbra } public final class org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderExtensionsKt { + public static final fun dependsOn (Lorg/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder;Lcom/android/build/api/dsl/AndroidSourceSet;)V public static final fun dependsOn (Lorg/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder;Lcom/android/build/gradle/api/AndroidSourceSet;)V public static final fun dependsOn (Lorg/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder;Lorg/jetbrains/kotlin/gradle/plugin/KotlinSourceSet;)V public static final fun kotlinSourceSet (Lorg/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder;Lorg/jetbrains/kotlin/gradle/plugin/KotlinSourceSet;)V diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderExtensions.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderExtensions.kt index 5c7c523b..196691af 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderExtensions.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderExtensions.kt @@ -1,6 +1,5 @@ package org.jetbrains.dokka.gradle -import com.android.build.gradle.api.AndroidSourceSet import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet /** @@ -13,7 +12,14 @@ fun GradleDokkaSourceSetBuilder.dependsOn(sourceSet: KotlinSourceSet) { /** * Convenient override to **append** source sets to [GradleDokkaSourceSetBuilder.dependentSourceSets] */ -fun GradleDokkaSourceSetBuilder.dependsOn(sourceSet: AndroidSourceSet) { +fun GradleDokkaSourceSetBuilder.dependsOn(@Suppress("DEPRECATION") sourceSet: com.android.build.gradle.api.AndroidSourceSet) { + dependsOn(DokkaSourceSetID(sourceSet.name)) +} + +/** + * Convenient override to **append** source sets to [GradleDokkaSourceSetBuilder.dependentSourceSets] + */ +fun GradleDokkaSourceSetBuilder.dependsOn(@Suppress("UnstableApiUsage") sourceSet: com.android.build.api.dsl.AndroidSourceSet) { dependsOn(DokkaSourceSetID(sourceSet.name)) } diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/isMainSourceSet.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/isMainSourceSet.kt index 15989217..c8b78367 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/isMainSourceSet.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/isMainSourceSet.kt @@ -11,7 +11,6 @@ internal fun Project.isMainSourceSet(sourceSet: KotlinSourceSet): Boolean { } internal fun isMainSourceSet(compilations: List<KotlinCompilation>): Boolean { - if (compilations.isEmpty()) return true return compilations.any { compilation -> isMainCompilation(compilation) } } diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/kotlinClasspathUtils.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/kotlinClasspathUtils.kt index ed77324f..e05b2075 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/kotlinClasspathUtils.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/kotlinClasspathUtils.kt @@ -27,6 +27,8 @@ internal fun Project.classpathOf(sourceSet: KotlinSourceSet): FileCollection { .map { compilation -> compilation.compileClasspathOf(project = this) } .reduce { acc, fileCollection -> acc + fileCollection } } else { + // Dokka suppresses source sets that do no have compilations + // since such configuration is invalid, it reports a warning or an error sourceSet.withAllDependentSourceSets() .toList() .map { it.kotlin.sourceDirectories } @@ -41,7 +43,7 @@ private fun KotlinCompilation.compileClasspathOf(project: Project): FileCollecti val platformDependencyFiles: FileCollection = (this as? AbstractKotlinNativeCompilation) ?.target?.project?.configurations - ?.findByName(this.defaultSourceSet.implementationMetadataConfigurationName) + ?.findByName(@Suppress("DEPRECATION") this.defaultSourceSet.implementationMetadataConfigurationName) // KT-58640 ?: project.files() return this.compileDependencyFiles + platformDependencyFiles + this.classpathOf(project) diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaMultiModuleTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaMultiModuleTask.kt index c1697ac1..7d6f60d2 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaMultiModuleTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaMultiModuleTask.kt @@ -92,8 +92,8 @@ abstract class DokkaMultiModuleTask : AbstractDokkaParentTask() { outputDir = outputDirectory.asFile.get(), cacheRoot = cacheRoot.asFile.orNull, pluginsConfiguration = buildPluginsConfiguration(), - failOnWarning = failOnWarning.get(), - offlineMode = offlineMode.get(), + failOnWarning = failOnWarning.get(), + offlineMode = offlineMode.get(), pluginsClasspath = plugins.resolve().toList(), modules = childDokkaTasks.map { dokkaTask -> DokkaModuleDescriptionImpl( diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAutoConfigurationTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAutoConfigurationTest.kt index 116104e8..7bd6986e 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAutoConfigurationTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAutoConfigurationTest.kt @@ -33,7 +33,7 @@ class AndroidAutoConfigurationTest { assertEquals( listOf( "androidTest", "androidTestDebug", "debug", "main", - "release", "test", "testDebug", "testRelease" + "release", "test", "testDebug", "testRelease", "androidTestRelease" ).sorted(), sourceSets.map { it.name }.sorted(), "Expected all default source sets being registered" @@ -67,15 +67,16 @@ class AndroidAutoConfigurationTest { project as ProjectInternal project.evaluate() - dokkaTasks.flatMap { it.dokkaSourceSets }.forEach { sourceSet -> + dokkaTasks.flatMap { it.dokkaSourceSets } + .filterNot { it.name == "androidTestRelease" && it.suppress.get() } // androidTestRelease has empty classpath, but it makes no sense for suppressed source set + .forEach { sourceSet -> /* There is no better way of checking for empty classpath at the moment (without resolving dependencies). We assume, that an empty classpath can be resolved We assume, that a non-empty classpath will not be able to resolve (no repositories defined) */ - - assertFailsWith<ResolveException> { sourceSet.classpath.files } + assertFailsWith<ResolveException>("SourceSet: " + sourceSet.name) { sourceSet.classpath.files } } } } diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/IsMainSourceSetTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/IsMainSourceSetTest.kt deleted file mode 100644 index c354c62f..00000000 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/IsMainSourceSetTest.kt +++ /dev/null @@ -1,15 +0,0 @@ -package org.jetbrains.dokka.gradle - -import org.jetbrains.dokka.gradle.kotlin.isMainSourceSet -import kotlin.test.Test -import kotlin.test.assertTrue - -class IsMainSourceSetTest { - @Test - fun `missing compilations will return true`() { - assertTrue( - isMainSourceSet(emptyList()), - "Expected 'isMainSourceSet' to return 'true' when no compilations are found" - ) - } -} |