diff --git a/libraries/reflect/Module.md b/libraries/reflect/Module.md new file mode 100644 index 0000000000000..2c744dc7ab693 --- /dev/null +++ b/libraries/reflect/Module.md @@ -0,0 +1,18 @@ +# Module kotlin-reflect + +## Kotlin JVM reflection extensions + +The library provides the runtime component that enables full support of the reflection features in `kotlin.reflect` package +and extensions for the reflection types. + +It's provided as an optional artifact separate from the standard library to reduce the required size of the runtime dependencies +for applications that do not use reflection features. + +# Package kotlin.reflect.full + +Extensions for [Kotlin reflection](https://kotlinlang.org/docs/reference/reflection.html) types like [kotlin.reflect.KClass], [kotlin.reflect.KType], and others. + +# Package kotlin.reflect.jvm + +Extensions for conversion between [Kotlin reflection](https://kotlinlang.org/docs/reference/reflection.html) and +Java reflection types and other JVM-specific extensions. diff --git a/libraries/tools/kotlin-stdlib-docs/build.gradle.kts b/libraries/tools/kotlin-stdlib-docs/build.gradle.kts index 1f3166b2907e4..496b42a089de4 100644 --- a/libraries/tools/kotlin-stdlib-docs/build.gradle.kts +++ b/libraries/tools/kotlin-stdlib-docs/build.gradle.kts @@ -64,7 +64,6 @@ fun createStdLibVersionedDocTask(version: String, isLatest: Boolean) = "kotlin.native.internal", "kotlin.jvm.functions", "kotlin.coroutines.jvm.internal", - "kotlin.reflect.jvm.internal" ) var kotlinLanguageVersion = version @@ -114,7 +113,6 @@ fun createStdLibVersionedDocTask(version: String, isLatest: Boolean) = sourceRoots.from("$kotlin_stdlib_dir/jvm/src") - sourceRoots.from("$kotlin_root/core/reflection.jvm/src") sourceRoots.from("$kotlin_stdlib_dir/jvm/runtime/kotlin/jvm/annotations") sourceRoots.from("$kotlin_stdlib_dir/jvm/runtime/kotlin/jvm/JvmClassMapping.kt") sourceRoots.from("$kotlin_stdlib_dir/jvm/runtime/kotlin/jvm/PurelyImplements.kt") @@ -220,6 +218,51 @@ fun createStdLibVersionedDocTask(version: String, isLatest: Boolean) = } } +fun createKotlinReflectVersionedDocTask(version: String, isLatest: Boolean) = + tasks.register("kotlin-reflect_" + version + (if (isLatest) "_latest" else "")) { + dependsOn(prepare) + + val kotlinReflectIncludeMd = file("$kotlin_root/libraries/reflect/Module.md") + + val kotlinReflectClasspath = fileTree("$kotlin_libs/kotlin-reflect") + + val kotlinLanguageVersion = version + + moduleName.set("kotlin-reflect") + + val moduleDirName = "kotlin-reflect" + with(pluginsMapConfiguration) { + put("org.jetbrains.dokka.base.DokkaBase", """{ "templatesDir": "$templatesDir" }""") + put("org.jetbrains.dokka.versioning.VersioningPlugin", """{ "version": "$version" }""") + } + if (isLatest) { + outputDirectory.set(file("$outputDirPartial/latest").resolve(moduleDirName)) + } else { + outputDirectory.set(file("$outputDirPartial/previous").resolve(moduleDirName).resolve(version)) + pluginsMapConfiguration.put("org.jetbrains.dokka.kotlinlang.VersionFilterPlugin", """{ "targetVersion": "$version" }""") + } + + dokkaSourceSets { + register("jvm") { + jdkVersion.set(8) + platform.set(Platform.jvm) + classpath.setFrom(kotlinReflectClasspath) + + displayName.set("JVM") + sourceRoots.from("$kotlin_root/core/reflection.jvm/src") + + skipDeprecated.set(false) + includes.from(kotlinReflectIncludeMd) + languageVersion.set(kotlinLanguageVersion) + noStdlibLink.set(true) + perPackageOption("kotlin.reflect.jvm.internal") { + suppress.set(true) + } + sourceLinksFromRoot() + } + } + } + fun createKotlinTestVersionedDocTask(version: String, isLatest: Boolean) = tasks.register("kotlin-test_" + version + (if (isLatest) "_latest" else "")) { dependsOn(prepare) @@ -413,15 +456,17 @@ gradle.projectsEvaluated { val buildLatestVersion by tasks.registering val latestStdlib = createStdLibVersionedDocTask(latestVersion, true) + val latestReflect = createKotlinReflectVersionedDocTask(latestVersion, true) val latestTest = createKotlinTestVersionedDocTask(latestVersion, true) - val latestAll = createAllLibsVersionedDocTask(latestVersion, true, latestStdlib, latestTest) + val latestAll = createAllLibsVersionedDocTask(latestVersion, true, latestStdlib, latestReflect, latestTest) - buildLatestVersion.configure { dependsOn(latestStdlib, latestTest, latestAll) } + buildLatestVersion.configure { dependsOn(latestStdlib, latestTest, latestReflect, latestAll) } versions.forEach { version -> val versionStdlib = createStdLibVersionedDocTask(version, false) + val versionReflect = createKotlinReflectVersionedDocTask(version, false) val versionTest = createKotlinTestVersionedDocTask(version, false) - val versionAll = createAllLibsVersionedDocTask(version, isLatest = false, versionStdlib, versionTest) + val versionAll = createAllLibsVersionedDocTask(version, isLatest = false, versionStdlib, versionReflect, versionTest) if (version != latestVersion) { latestAll.configure { dependsOn(versionAll) } } diff --git a/libraries/tools/kotlin-stdlib-docs/kotlin_big/build.gradle.kts b/libraries/tools/kotlin-stdlib-docs/kotlin_big/build.gradle.kts index 60a2a8b7a8f0a..7cfa1e04bfabe 100644 --- a/libraries/tools/kotlin-stdlib-docs/kotlin_big/build.gradle.kts +++ b/libraries/tools/kotlin-stdlib-docs/kotlin_big/build.gradle.kts @@ -34,6 +34,7 @@ val modules = listOf( "kotlin-stdlib-jdk7", "kotlin-stdlib-jdk8", "kotlin-stdlib-js", + "kotlin-reflect", "kotlin-test", "kotlin-test-js", "kotlin-test-junit5",